# HG changeset patch # User Rob Landley # Date 1164583653 18000 # Node ID d046f8d1401ef1a2a67193561c5ba26901bd78ed # Parent 00e73c4dea6612f26bccd4ecdb5e8fd4ac7626e3 Trawling through the archives: a broken test, an unnecessary memset, and a unrolling a small memmove. diff -r 00e73c4dea66 -r d046f8d1401e lib/bunzip.c --- a/lib/bunzip.c Sun Nov 26 17:19:18 2006 -0500 +++ b/lib/bunzip.c Sun Nov 26 18:27:33 2006 -0500 @@ -91,7 +91,7 @@ // If we need to read more data from file into byte buffer, do so if (bd->inbufPos == bd->inbufCount) { - if (!(bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE))) + if (0 >= (bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE))) longjmp(bd->jmpbuf, RETVAL_UNEXPECTED_INPUT_EOF); bd->inbufPos = 0; } @@ -155,7 +155,6 @@ // values were present. We make a translation table to convert the symbols // back to the corresponding bytes. t = get_bits(bd, 16); - memset(symToByte,0,256); symTotal = 0; for (i=0; i<16; i++) { if (t&(1<<(15-i))) { @@ -182,7 +181,7 @@ // Decode MTF to get the next selector uc = mtfSymbol[j]; - memmove(mtfSymbol+1, mtfSymbol, j); + for (k=j; k; k--) mtfSymbol[k] = mtfSymbol[k-1]; mtfSymbol[0] = selectors[i] = uc; } // Read the huffman coding tables for each group, which code for symTotal