Diff
Not logged in

Differences From:

File src/delta.c part of check-in [e63a9fd9d0] - Fixed many uninitialized variable warnings and some potential bug found via -Wall -Werror on gcc. by jnc on 2007-09-25 21:21:35. Also file src/delta.c part of check-in [92291035fe] - Merged the compiler warning fixes into mainstream by jnc on 2007-09-25 21:28:30. Also file src/delta.c part of check-in [d0305b305a] - Merged mainline into my branch to get the newest application. by aku on 2007-12-05 08:07:46. [view]

To:

File src/delta.c part of check-in [61ddd63b72] - Work toward making fossil work better on large repositories. This version implements a cache in the content manager. It is not clear yet if this is necessarily a good idea - this check-in might end up on an abandoned branch at some point. by drh on 2008-03-06 22:58:48. [view]

@@ -197,22 +197,29 @@
 
 /*
 ** Compute a 32-bit checksum on the N-byte buffer.  Return the result.
 */
-static unsigned int checksum(const char *zIn, int N){
-  const unsigned char *z = (const unsigned char*)zIn;
-  unsigned int sum = 0;
-  while( N>=4 ){
+static unsigned int checksum(const char *zIn, size_t N){
+  const unsigned char *z = (const unsigned char *)zIn;
+  unsigned sum = 0;
+  while(N >= 16){
+    sum += ((unsigned)z[0] + z[4] + z[8] + z[12]) << 24;
+    sum += ((unsigned)z[1] + z[5] + z[9] + z[13]) << 16;
+    sum += ((unsigned)z[2] + z[6] + z[10]+ z[14]) << 8;
+    sum += ((unsigned)z[3] + z[7] + z[11]+ z[15]);
+    z += 16;
+    N -= 16;
+  }
+  while(N >= 4){
     sum += (z[0]<<24) | (z[1]<<16) | (z[2]<<8) | z[3];
     z += 4;
     N -= 4;
   }
-  if( N>0 ){
-    unsigned char zBuf[4];
-    memset(zBuf, 0, sizeof(zBuf));
-    memcpy(zBuf, z, N);
-    z = zBuf;
-    sum += (z[0]<<24) | (z[1]<<16) | (z[2]<<8) | z[3];
+  switch(N){
+    case 3:   sum += (z[2] << 8);
+    case 2:   sum += (z[1] << 16);
+    case 1:   sum += (z[0] << 24);
+    default:  ;
   }
   return sum;
 }