Mercurial > hg > toybox
comparison lib/bunzip.c @ 60:23aac9d42234
Turn a memmove into a while(), reducing running time by 3.5% in my tests.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 17 Jan 2007 18:18:50 -0500 |
parents | e82ae73acbd7 |
children | d6ece20e13ce |
comparison
equal
deleted
inserted
replaced
59:e82ae73acbd7 | 60:23aac9d42234 |
---|---|
344 Another instance of the first symbol in the mtf array, position 0, | 344 Another instance of the first symbol in the mtf array, position 0, |
345 would have been handled as part of a run.) */ | 345 would have been handled as part of a run.) */ |
346 if (dbufCount>=dbufSize) return RETVAL_DATA_ERROR; | 346 if (dbufCount>=dbufSize) return RETVAL_DATA_ERROR; |
347 i = nextSym - 1; | 347 i = nextSym - 1; |
348 uc = mtfSymbol[i]; | 348 uc = mtfSymbol[i]; |
349 memmove(mtfSymbol+1, mtfSymbol, i); | 349 // On my laptop, unrolling this memmove() into a loop costs 11 bytes |
350 // but shaves 3.5% off the total running time. | |
351 while(i--) mtfSymbol[i+1] = mtfSymbol[i]; | |
350 mtfSymbol[0] = uc; | 352 mtfSymbol[0] = uc; |
351 uc = symToByte[uc]; | 353 uc = symToByte[uc]; |
352 | 354 |
353 // We have our literal byte. Save it into dbuf. | 355 // We have our literal byte. Save it into dbuf. |
354 byteCount[uc]++; | 356 byteCount[uc]++; |