changeset 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
files lib/bunzip.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/bunzip.c	Wed Jan 17 16:58:51 2007 -0500
+++ b/lib/bunzip.c	Wed Jan 17 18:18:50 2007 -0500
@@ -346,7 +346,9 @@
 		if (dbufCount>=dbufSize) return RETVAL_DATA_ERROR;
 		i = nextSym - 1;
 		uc = mtfSymbol[i];
-		memmove(mtfSymbol+1, mtfSymbol, i);
+		// On my laptop, unrolling this memmove() into a loop costs 11 bytes
+		// but shaves 3.5% off the total running time.
+		while(i--) mtfSymbol[i+1] = mtfSymbol[i];
 		mtfSymbol[0] = uc;
 		uc = symToByte[uc];