summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 90bd932)
raw | patch | inline | side by side (parent: 90bd932)
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 08:37:57 +0000 (00:37 -0800) |
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 835d82c9939644faa808bb2f616136549af521db..ceb35c3276579b22b379f0fe1ccaf2a4a76fc61a 100644 (file)
--- a/diffcore-delta.c
+++ b/diffcore-delta.c
}
static struct spanhash_top *add_spanhash(struct spanhash_top *top,
- unsigned long hashval)
+ unsigned long hashval, int cnt)
{
int bucket, lim;
struct spanhash *h;
h = &(top->data[bucket++]);
if (!h->cnt) {
h->hashval = hashval;
- h->cnt = 1;
+ h->cnt = cnt;
top->free--;
if (top->free < 0)
return spanhash_rehash(top);
return top;
}
if (h->hashval == hashval) {
- h->cnt++;
+ h->cnt += cnt;
return top;
}
if (lim <= bucket)
static struct spanhash_top *hash_chars(unsigned char *buf, unsigned long sz)
{
- int i;
+ int i, n;
unsigned long accum1, accum2, hashval;
struct spanhash_top *hash;
hash->free = INITIAL_FREE(i);
memset(hash->data, 0, sizeof(struct spanhash) * (1<<i));
- /* an 8-byte shift register made of accum1 and accum2. New
- * bytes come at LSB of accum2, and shifted up to accum1
- */
- for (i = accum1 = accum2 = 0; i < 7; i++, sz--) {
- accum1 = (accum1 << 8) | (accum2 >> 24);
- accum2 = (accum2 << 8) | *buf++;
- }
+ n = 0;
+ accum1 = accum2 = 0;
while (sz) {
- accum1 = (accum1 << 8) | (accum2 >> 24);
- accum2 = (accum2 << 8) | *buf++;
- hashval = (accum1 + accum2 * 0x61) % HASHBASE;
- hash = add_spanhash(hash, hashval);
+ unsigned long c = *buf++;
sz--;
+ accum1 = (accum1 << 7) | (accum2 >> 25);
+ accum2 = (accum2 << 7) | (accum1 >> 25);
+ accum1 += c;
+ if (++n < 64 && c != '\n')
+ continue;
+ hashval = (accum1 + accum2 * 0x61) % HASHBASE;
+ hash = add_spanhash(hash, hashval, n);
+ n = 0;
+ accum1 = accum2 = 0;
}
return hash;
}
struct spanhash_top *src_count, *dst_count;
unsigned long sc, la;
- if (src_size < 8 || dst_size < 8)
- return -1;
-
src_count = dst_count = NULL;
if (src_count_p)
src_count = *src_count_p;