Browse Source

Small tweak to make wocky much faster

master
stew3254 2 years ago
parent
commit
43e9b7a621
  1. 12
      wocky.c

12
wocky.c

@ -6,15 +6,6 @@
#include "sys/stat.h"
#include "unistd.h"
//Print to binary
int btoi(char* b, int len) {
int n = 0;
for (int i = 0; i < len; ++i) {
n += (b[i] - '0') << (len-1-i);
}
return n;
}
//LZ77 decompression (No Error checking)
void wocky(char *buff, int buff_len, FILE *f) {
int table_max = 32, table_len = 1;
@ -27,9 +18,8 @@ void wocky(char *buff, int buff_len, FILE *f) {
int bin_index = 0;
for (int i = 0; i < len; ++i) {
bin_int[i] = buff[buff_index+i];
bin_index += (bin_int[i] - '0') << (len-1-i);
}
//Get binary index
bin_index = btoi(bin_int, len);
char *s = NULL;
if (table[bin_index] != NULL) {

Loading…
Cancel
Save