##// END OF EJS Templates
bdiff: switch to lyhash...
Matt Mackall -
r5342:d0c48891 default
parent child Browse files
Show More
@@ -59,14 +59,9 b' struct hunklist {'
59 59 struct hunk *base, *head;
60 60 };
61 61
62 static inline uint32_t rol32(uint32_t word, unsigned int shift)
63 {
64 return (word << shift) | (word >> (32 - shift));
65 }
66
67 62 int splitlines(const char *a, int len, struct line **lr)
68 63 {
69 int g, h, i;
64 int h, i;
70 65 const char *p, *b = a;
71 66 const char * const plast = a + len - 1;
72 67 struct line *l;
@@ -84,24 +79,17 b' int splitlines(const char *a, int len, s'
84 79 /* build the line array and calculate hashes */
85 80 h = 0;
86 81 for (p = a; p < a + len; p++) {
87 /*
88 * a simple hash from GNU diff, with better collision
89 * resistance from hashpjw. this slows down common
90 * case by 10%, but speeds up worst case by 100x.
91 */
92 h = *p + rol32(h, 7);
93 if ((g = h & 0xf0000000)) {
94 h ^= g >> 24;
95 h ^= g;
96 }
82 /* Leonid Yuriev's hash */
83 h = (h * 1664525) + *p + 1013904223;
84
97 85 if (*p == '\n' || p == plast) {
86 l->h = h;
87 h = 0;
98 88 l->len = p - b + 1;
99 l->h = h * l->len;
100 89 l->l = b;
101 90 l->n = INT_MAX;
102 91 l++;
103 92 b = p + 1;
104 h = 0;
105 93 }
106 94 }
107 95
General Comments 0
You need to be logged in to leave comments. Login now