summaryrefslogtreecommitdiff
path: root/diff-delta.c
diff options
context:
space:
mode:
authorPeter Eriksen <s022018@student.dtu.dk>2006-02-04 23:54:01 +0100
committerJunio C Hamano <junkio@cox.net>2006-02-05 13:45:01 -0800
commit04fe2a1706b4bd71b604bfe7d7295064440872cf (patch)
tree5cba41b0a51cc54f8433619afd0885aae77bfd11 /diff-delta.c
parent9523a4c2fcd7bbccbbddb998eef891ae83cf91a3 (diff)
downloadgit-04fe2a1706b4bd71b604bfe7d7295064440872cf.tar.gz
Use adler32() from zlib instead of defining our own.
Since we already depend on zlib, we don't need to define our own adler32(). Spotted by oprofile. Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff-delta.c')
-rw-r--r--diff-delta.c39
1 files changed, 1 insertions, 38 deletions
diff --git a/diff-delta.c b/diff-delta.c
index 890986eeb0..c2f656ae39 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include "delta.h"
+#include "zlib.h"
/* block size: min = 16, max = 64k, power of 2 */
@@ -30,44 +31,6 @@
#define GR_PRIME 0x9e370001
#define HASH(v, b) (((unsigned int)(v) * GR_PRIME) >> (32 - (b)))
-/* largest prime smaller than 65536 */
-#define BASE 65521
-
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-#define NMAX 5552
-
-#define DO1(buf, i) { s1 += buf[i]; s2 += s1; }
-#define DO2(buf, i) DO1(buf, i); DO1(buf, i + 1);
-#define DO4(buf, i) DO2(buf, i); DO2(buf, i + 2);
-#define DO8(buf, i) DO4(buf, i); DO4(buf, i + 4);
-#define DO16(buf) DO8(buf, 0); DO8(buf, 8);
-
-static unsigned int adler32(unsigned int adler, const unsigned char *buf, int len)
-{
- int k;
- unsigned int s1 = adler & 0xffff;
- unsigned int s2 = adler >> 16;
-
- while (len > 0) {
- k = MIN(len, NMAX);
- len -= k;
- while (k >= 16) {
- DO16(buf);
- buf += 16;
- k -= 16;
- }
- if (k != 0)
- do {
- s1 += *buf++;
- s2 += s1;
- } while (--k);
- s1 %= BASE;
- s2 %= BASE;
- }
-
- return (s2 << 16) | s1;
-}
-
static unsigned int hashbits(unsigned int size)
{
unsigned int val = 1, bits = 0;