File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ LZSSDecoder::status LZSSDecoder::handle_state() {
216
216
case FSM_1:
217
217
putc (c);
218
218
buffer[r++] = c;
219
- r &= (N - 1 ); // equivalent to r = r % N
219
+ r &= (N - 1 ); // equivalent to r = r % N when N is a power of 2
220
220
221
221
this ->state = FSM_0;
222
222
break ;
@@ -226,10 +226,16 @@ LZSSDecoder::status LZSSDecoder::handle_state() {
226
226
break ;
227
227
case FSM_3: {
228
228
int j = c;
229
- for (int k = 0 ; k <= j + 1 ; k++) { // TODO improve by using memcpy
230
- c = buffer[(this ->i + k) & (N - 1 )]; // equivalent to buffer[(i+k) % N]
229
+
230
+ // This is where the actual decompression takes place: we look into the local buffer for reuse
231
+ // of byte chunks. This can be improved by means of memcpy and by changing the putc function
232
+ // into a put_buf function in order to avoid buffering on the other end.
233
+ // TODO improve this section of code
234
+ for (int k = 0 ; k <= j + 1 ; k++) {
235
+ c = buffer[(this ->i + k) & (N - 1 )]; // equivalent to buffer[(i+k) % N] when N is a power of 2
231
236
putc (c);
232
- buffer[r++] = c; r &= (N - 1 ); // equivalent to r = r % N
237
+ buffer[r++] = c;
238
+ r &= (N - 1 ); // equivalent to r = r % N
233
239
}
234
240
this ->state = FSM_0;
235
241
You can’t perform that action at this time.
0 commit comments