xdiff/xhistogram: rework handling of recursed results
Previously we were over-complicating matters by trying to combine the recursed results. Now, terminate immediately if a recursive call failed and return its result. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tay Ray Chuan committed
Aug 1, 2011 at 12:20 UTC
19f7a9c57785161cdfaa6036eb0ef90853333724
1 file changed
+9
-6
xdiff/xhistogram.c
+9
-6
@@ -339,21 +339,24 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
339
if (find_lcs(&index, &lcs, line1, count1, line2, count2))
340
result = fall_back_to_classic_diff(&index, line1, count1, line2, count2);
341
else {
342
- result = 0;
342
if (lcs.begin1 == 0 && lcs.begin2 == 0) {
343
int ptr;
344
for (ptr = 0; ptr < count1; ptr++)
345
env->xdf1.rchg[line1 + ptr - 1] = 1;
346
for (ptr = 0; ptr < count2; ptr++)
347
env->xdf2.rchg[line2 + ptr - 1] = 1;
348
+ result = 0;
349
} else {
350
result = histogram_diff(xpp, env,
351
- line1, lcs.begin1 - line1,
352
- line2, lcs.begin2 - line2);
351
+ line1, lcs.begin1 - line1,
352
+ line2, lcs.begin2 - line2);
353
+ if (result)
354
+ goto cleanup;
355
result = histogram_diff(xpp, env,
354
- lcs.end1 + 1, LINE_END(1) - lcs.end1,
355
- lcs.end2 + 1, LINE_END(2) - lcs.end2);
356
- result *= -1;
356
+ lcs.end1 + 1, LINE_END(1) - lcs.end1,
357
+ lcs.end2 + 1, LINE_END(2) - lcs.end2);
358
+ if (result)
359
+ goto cleanup;
360
}
361
}
362