diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c index 458acf92b49e4be54f780f4a0512d91502a5aa67_bWVyY3VyaWFsL2JkaWZmLmM=..d0c48891dd4a7334548e54cfb33d39e26a7b24d7_bWVyY3VyaWFsL2JkaWZmLmM= 100644 --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -59,10 +59,5 @@ struct hunk *base, *head; }; -static inline uint32_t rol32(uint32_t word, unsigned int shift) -{ - return (word << shift) | (word >> (32 - shift)); -} - int splitlines(const char *a, int len, struct line **lr) { @@ -67,6 +62,6 @@ int splitlines(const char *a, int len, struct line **lr) { - int g, h, i; + int h, i; const char *p, *b = a; const char * const plast = a + len - 1; struct line *l; @@ -84,14 +79,7 @@ /* build the line array and calculate hashes */ h = 0; for (p = a; p < a + len; p++) { - /* - * a simple hash from GNU diff, with better collision - * resistance from hashpjw. this slows down common - * case by 10%, but speeds up worst case by 100x. - */ - h = *p + rol32(h, 7); - if ((g = h & 0xf0000000)) { - h ^= g >> 24; - h ^= g; - } + /* Leonid Yuriev's hash */ + h = (h * 1664525) + *p + 1013904223; + if (*p == '\n' || p == plast) { @@ -97,2 +85,4 @@ if (*p == '\n' || p == plast) { + l->h = h; + h = 0; l->len = p - b + 1; @@ -98,6 +88,5 @@ l->len = p - b + 1; - l->h = h * l->len; l->l = b; l->n = INT_MAX; l++; b = p + 1; @@ -100,8 +89,7 @@ l->l = b; l->n = INT_MAX; l++; b = p + 1; - h = 0; } }