Skip to content

Commit 5c11cf6

Browse files
committed
more optimizations
1 parent aa1c3be commit 5c11cf6

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

compress/compress5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def mask(n):
55
m = 1
66
while m <= n:
77
m *= 2
8-
return m-1
8+
return m
99

1010
def toBitmap(length, decider):
1111
def encodeByte(offset, decider):
@@ -109,7 +109,7 @@ def encodeList(ww):
109109
with open("../sizes.h", "w") as sizes:
110110
sizes.write("#define NUM_WORDS %u\n" % len(allwords))
111111
sizes.write("#define NUM_ANSWERS %u\n" % len(answers))
112-
sizes.write("#define NUM_ANSWERS_MASK %u" % mask(len(answers)))
112+
sizes.write("#define NUM_ANSWERS_ROUNDED_UP_POW2 %u" % mask(len(answers)))
113113

114114
#print(sum(map(len, encoded)))
115115
#print(max(map(len, encoded)))

decode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ uint8_t filterWord(char* s) {
6363
w = (w << 5) | (s[i]-'A');
6464

6565
i = s[0]-'A';
66-
uint16_t n = words[i+1].wordNumber - words[i].wordNumber;
6766
currentWord = 0;
6867
blobPtr = wordBlob + words[i].blobOffset;
69-
for (uint16_t j=0; j<n; j++) {
68+
for (uint16_t j=words[i+1].wordNumber - words[i].wordNumber; j; j--) {
7069
updateWord();
7170
if (currentWord >= w) {
7271
return currentWord == w;

0 commit comments

Comments
 (0)