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