equal
deleted
inserted
replaced
146 } |
146 } |
147 |
147 |
148 static int longest_match(struct line *a, struct line *b, struct pos *pos, |
148 static int longest_match(struct line *a, struct line *b, struct pos *pos, |
149 int a1, int a2, int b1, int b2, int *omi, int *omj) |
149 int a1, int a2, int b1, int b2, int *omi, int *omj) |
150 { |
150 { |
151 int mi = a1, mj = b1, mk = 0, mb = 0, i, j, k, half; |
151 int mi = a1, mj = b1, mk = 0, i, j, k, half; |
152 |
152 |
153 /* window our search on large regions to better bound |
153 /* window our search on large regions to better bound |
154 worst-case performance. by choosing a window at the end, we |
154 worst-case performance. by choosing a window at the end, we |
155 reduce skipping overhead on the b chains. */ |
155 reduce skipping overhead on the b chains. */ |
156 if (a2 - a1 > 30000) |
156 if (a2 - a1 > 30000) |
193 if (mk) { |
193 if (mk) { |
194 mi = mi - mk + 1; |
194 mi = mi - mk + 1; |
195 mj = mj - mk + 1; |
195 mj = mj - mk + 1; |
196 } |
196 } |
197 |
197 |
198 /* expand match to include neighboring popular lines */ |
198 /* expand match to include subsequent popular lines */ |
199 while (mi - mb > a1 && mj - mb > b1 && |
|
200 a[mi - mb - 1].e == b[mj - mb - 1].e) |
|
201 mb++; |
|
202 while (mi + mk < a2 && mj + mk < b2 && |
199 while (mi + mk < a2 && mj + mk < b2 && |
203 a[mi + mk].e == b[mj + mk].e) |
200 a[mi + mk].e == b[mj + mk].e) |
204 mk++; |
201 mk++; |
205 |
202 |
206 *omi = mi - mb; |
203 *omi = mi; |
207 *omj = mj - mb; |
204 *omj = mj; |
208 |
205 |
209 return mk + mb; |
206 return mk; |
210 } |
207 } |
211 |
208 |
212 static struct hunk *recurse(struct line *a, struct line *b, struct pos *pos, |
209 static struct hunk *recurse(struct line *a, struct line *b, struct pos *pos, |
213 int a1, int a2, int b1, int b2, struct hunk *l) |
210 int a1, int a2, int b1, int b2, struct hunk *l) |
214 { |
211 { |