Show More
@@ -49,7 +49,7 b' static uint32_t htonl(uint32_t x)' | |||
|
49 | 49 | #include "util.h" |
|
50 | 50 | |
|
51 | 51 | struct line { |
|
52 | int h, len, n, e; | |
|
52 | int hash, len, n, e; | |
|
53 | 53 | const char *l; |
|
54 | 54 | }; |
|
55 | 55 | |
@@ -65,7 +65,7 b' struct hunk {' | |||
|
65 | 65 | |
|
66 | 66 | static int splitlines(const char *a, int len, struct line **lr) |
|
67 | 67 | { |
|
68 | unsigned h; | |
|
68 | unsigned hash; | |
|
69 | 69 | int i; |
|
70 | 70 | const char *p, *b = a; |
|
71 | 71 | const char * const plast = a + len - 1; |
@@ -82,14 +82,14 b' static int splitlines(const char *a, int' | |||
|
82 | 82 | return -1; |
|
83 | 83 | |
|
84 | 84 | /* build the line array and calculate hashes */ |
|
85 | h = 0; | |
|
85 | hash = 0; | |
|
86 | 86 | for (p = a; p < a + len; p++) { |
|
87 | 87 | /* Leonid Yuriev's hash */ |
|
88 | h = (h * 1664525) + (unsigned char)*p + 1013904223; | |
|
88 | hash = (hash * 1664525) + (unsigned char)*p + 1013904223; | |
|
89 | 89 | |
|
90 | 90 | if (*p == '\n' || p == plast) { |
|
91 | l->h = h; | |
|
92 | h = 0; | |
|
91 | l->hash = hash; | |
|
92 | hash = 0; | |
|
93 | 93 | l->len = p - b + 1; |
|
94 | 94 | l->l = b; |
|
95 | 95 | l->n = INT_MAX; |
@@ -99,7 +99,7 b' static int splitlines(const char *a, int' | |||
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | /* set up a sentinel */ |
|
102 | l->h = 0; | |
|
102 | l->hash = 0; | |
|
103 | 103 | l->len = 0; |
|
104 | 104 | l->l = a + len; |
|
105 | 105 | return i - 1; |
@@ -107,7 +107,7 b' static int splitlines(const char *a, int' | |||
|
107 | 107 | |
|
108 | 108 | static inline int cmp(struct line *a, struct line *b) |
|
109 | 109 | { |
|
110 | return a->h != b->h || a->len != b->len || memcmp(a->l, b->l, a->len); | |
|
110 | return a->hash != b->hash || a->len != b->len || memcmp(a->l, b->l, a->len); | |
|
111 | 111 | } |
|
112 | 112 | |
|
113 | 113 | static int equatelines(struct line *a, int an, struct line *b, int bn) |
@@ -140,7 +140,7 b' static int equatelines(struct line *a, i' | |||
|
140 | 140 | /* add lines to the hash table chains */ |
|
141 | 141 | for (i = bn - 1; i >= 0; i--) { |
|
142 | 142 | /* find the equivalence class */ |
|
143 | for (j = b[i].h & buckets; h[j].pos != INT_MAX; | |
|
143 | for (j = b[i].hash & buckets; h[j].pos != INT_MAX; | |
|
144 | 144 | j = (j + 1) & buckets) |
|
145 | 145 | if (!cmp(b + i, b + h[j].pos)) |
|
146 | 146 | break; |
@@ -158,7 +158,7 b' static int equatelines(struct line *a, i' | |||
|
158 | 158 | /* match items in a to their equivalence class in b */ |
|
159 | 159 | for (i = 0; i < an; i++) { |
|
160 | 160 | /* find the equivalence class */ |
|
161 | for (j = a[i].h & buckets; h[j].pos != INT_MAX; | |
|
161 | for (j = a[i].hash & buckets; h[j].pos != INT_MAX; | |
|
162 | 162 | j = (j + 1) & buckets) |
|
163 | 163 | if (!cmp(a + i, b + h[j].pos)) |
|
164 | 164 | break; |
General Comments 0
You need to be logged in to leave comments.
Login now