summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c7ceba)
raw | patch | inline | side by side (parent: 3c7ceba)
author | Linus Torvalds <torvalds@osdl.org> | |
Wed, 15 Mar 2006 08:37:57 +0000 (00:37 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 15 Mar 2006 21:19:27 +0000 (13:19 -0800) |
The rotating 64-bit number was not really rotating, and worse
yet ulong was longer than 64-bit on 64-bit architectures X-<.
Signed-off-by: Junio C Hamano <junkio@cox.net>
yet ulong was longer than 64-bit on 64-bit architectures X-<.
Signed-off-by: Junio C Hamano <junkio@cox.net>
diffcore-delta.c | patch | blob | history |
diff --git a/diffcore-delta.c b/diffcore-delta.c
index ceb35c3276579b22b379f0fe1ccaf2a4a76fc61a..7338a40c5964ae6ddfb855465249fc1a2fa5a2a3 100644 (file)
--- a/diffcore-delta.c
+++ b/diffcore-delta.c
#define HASHBASE 107927
struct spanhash {
- unsigned long hashval;
- unsigned long cnt;
+ unsigned int hashval;
+ unsigned int cnt;
};
struct spanhash_top {
int alloc_log2;
};
static struct spanhash *spanhash_find(struct spanhash_top *top,
- unsigned long hashval)
+ unsigned int hashval)
{
int sz = 1 << top->alloc_log2;
int bucket = hashval & (sz - 1);
}
static struct spanhash_top *add_spanhash(struct spanhash_top *top,
- unsigned long hashval, int cnt)
+ unsigned int hashval, int cnt)
{
int bucket, lim;
struct spanhash *h;
}
}
-static struct spanhash_top *hash_chars(unsigned char *buf, unsigned long sz)
+static struct spanhash_top *hash_chars(unsigned char *buf, unsigned int sz)
{
int i, n;
- unsigned long accum1, accum2, hashval;
+ unsigned int accum1, accum2, hashval;
struct spanhash_top *hash;
i = INITIAL_HASH_SIZE;
n = 0;
accum1 = accum2 = 0;
while (sz) {
- unsigned long c = *buf++;
+ unsigned int c = *buf++;
+ unsigned int old_1 = accum1;
sz--;
- accum1 = (accum1 << 7) | (accum2 >> 25);
- accum2 = (accum2 << 7) | (accum1 >> 25);
+ accum1 = (accum1 << 7) ^ (accum2 >> 25);
+ accum2 = (accum2 << 7) ^ (old_1 >> 25);
accum1 += c;
if (++n < 64 && c != '\n')
continue;