##// END OF EJS Templates
I have spotted the biggest bottleneck in "bdiff.c". Actually it was...
Christoph Spiel -
r5339:058e93c3 default
parent child Browse files
Show More
@@ -117,17 +117,24 b' int inline cmp(struct line *a, struct li'
117 static int equatelines(struct line *a, int an, struct line *b, int bn)
117 static int equatelines(struct line *a, int an, struct line *b, int bn)
118 {
118 {
119 int i, j, buckets = 1, t;
119 int i, j, buckets = 1, t;
120 int scale = 32;
120 struct pos *h;
121 struct pos *h;
121
122
122 /* build a hash table of the next highest power of 2 */
123 /* build a hash table of the next highest power of 2 */
123 while (buckets < bn + 1)
124 while (buckets < bn + 1)
124 buckets *= 2;
125 buckets *= 2;
125
126
126 h = (struct pos *)malloc(buckets * sizeof(struct pos));
127 /* try to allocate a large hash table to avoid collisions */
127 buckets = buckets - 1;
128 do {
129 scale /= 2;
130 h = (struct pos *)malloc(scale * buckets * sizeof(struct pos));
131 } while (!h && scale != 1);
132
128 if (!h)
133 if (!h)
129 return 0;
134 return 0;
130
135
136 buckets = buckets * scale - 1;
137
131 /* clear the hash table */
138 /* clear the hash table */
132 for (i = 0; i <= buckets; i++) {
139 for (i = 0; i <= buckets; i++) {
133 h[i].pos = -1;
140 h[i].pos = -1;
General Comments 0
You need to be logged in to leave comments. Login now