Show More
@@ -106,19 +106,19 b' int inline cmp(struct line *a, struct li' | |||
|
106 | 106 | |
|
107 | 107 | static int equatelines(struct line *a, int an, struct line *b, int bn) |
|
108 | 108 | { |
|
109 | int i, j, buckets = 1, t; | |
|
110 | int scale = 32; | |
|
111 | struct pos *h; | |
|
109 | int i, j, buckets = 1, t, scale; | |
|
110 | struct pos *h = NULL; | |
|
112 | 111 | |
|
113 | 112 | /* build a hash table of the next highest power of 2 */ |
|
114 | 113 | while (buckets < bn + 1) |
|
115 | 114 | buckets *= 2; |
|
116 | 115 | |
|
117 | 116 | /* try to allocate a large hash table to avoid collisions */ |
|
118 | do { | |
|
119 | scale /= 2; | |
|
117 | for (scale = 4; scale; scale /= 2) { | |
|
120 | 118 | h = (struct pos *)malloc(scale * buckets * sizeof(struct pos)); |
|
121 | } while (!h && scale != 1); | |
|
119 | if (h) | |
|
120 | break; | |
|
121 | } | |
|
122 | 122 | |
|
123 | 123 | if (!h) |
|
124 | 124 | return 0; |
@@ -147,7 +147,7 b' static int equatelines(struct line *a, i' | |||
|
147 | 147 | } |
|
148 | 148 | |
|
149 | 149 | /* compute popularity threshold */ |
|
150 |
t = (bn >= |
|
|
150 | t = (bn >= 4000) ? bn / 1000 : bn + 1; | |
|
151 | 151 | |
|
152 | 152 | /* match items in a to their equivalence class in b */ |
|
153 | 153 | for (i = 0; i < an; i++) { |
General Comments 0
You need to be logged in to leave comments.
Login now