Commit Diff


commit - 9f656b2046b04aeb0528704d098cf48c329ce991
commit + b7bf7afc7c0ce730a430ef6e47ca359c97fef2ff
blob - a2405479df91c6faf091af2167f3f8f0b954f5d7
blob + f12135df2db1ceee67a5a57b7514abaf2d1b9486
--- lib/deltify.c
+++ lib/deltify.c
@@ -28,6 +28,7 @@
 #include "got_error.h"
 
 #include "got_lib_deltify.h"
+#include "murmurhash2.h"
 
 #ifndef MIN
 #define	MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
@@ -84,17 +85,10 @@ static uint32_t geartab[256] = {
     0xf1f6e72c, 0x5551128a, 0x83af87e2, 0x6f0342ba,
 };
 
-static uint64_t
+static uint32_t
 hashblk(const unsigned char *p, off_t n)
 {
-	unsigned char buf[SHA1_DIGEST_LENGTH];
-	uint64_t h;
-	SHA1_CTX ctx;
-	SHA1Init(&ctx);
-	SHA1Update(&ctx, p, n);
-	SHA1Final(buf, &ctx);
-	memcpy(&h, buf, sizeof(h));
-	return be64toh(h);
+	return murmurhash2(p, n, 0x1d7c5ac3);
 }
 
 static const struct got_error *
@@ -244,7 +238,7 @@ lookupblk(struct got_delta_block **block, struct got_d
     unsigned char *p, off_t len, FILE *basefile, off_t basefile_offset0)
 {
 	int i;
-	uint64_t h;
+	uint32_t h;
 	uint8_t buf[GOT_DELTIFY_MAXCHUNK];
 	size_t r;
 
@@ -275,7 +269,7 @@ lookupblk_mem(struct got_delta_block **block, struct g
     unsigned char *p, off_t len, uint8_t *basedata, off_t basefile_offset0)
 {
 	int i;
-	uint64_t h;
+	uint32_t h;
 	uint8_t *b;
 
 	*block = NULL;
@@ -357,7 +351,7 @@ got_deltify_init(struct got_delta_table **dt, FILE *f,
     off_t filesize)
 {
 	const struct got_error *err = NULL;
-	uint64_t h;
+	uint32_t h;
 	const off_t offset0 = fileoffset;
 
 	*dt = calloc(1, sizeof(**dt));
blob - b903bbecf5905f866e82fb63306b28d3e7b6366e
blob + 3685d581c00c312631e3fc1877509c48999690d4
--- regress/deltify/Makefile
+++ regress/deltify/Makefile
@@ -1,7 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = deltify_test
-SRCS = deltify.c error.c opentemp.c sha1.c deltify_test.c
+SRCS = deltify.c error.c opentemp.c sha1.c deltify_test.c murmurhash2.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lz