mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
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>
This commit is contained in:
parent
739864b1ff
commit
19f7a9c577
|
@ -339,21 +339,24 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
|
||||||
if (find_lcs(&index, &lcs, line1, count1, line2, count2))
|
if (find_lcs(&index, &lcs, line1, count1, line2, count2))
|
||||||
result = fall_back_to_classic_diff(&index, line1, count1, line2, count2);
|
result = fall_back_to_classic_diff(&index, line1, count1, line2, count2);
|
||||||
else {
|
else {
|
||||||
result = 0;
|
|
||||||
if (lcs.begin1 == 0 && lcs.begin2 == 0) {
|
if (lcs.begin1 == 0 && lcs.begin2 == 0) {
|
||||||
int ptr;
|
int ptr;
|
||||||
for (ptr = 0; ptr < count1; ptr++)
|
for (ptr = 0; ptr < count1; ptr++)
|
||||||
env->xdf1.rchg[line1 + ptr - 1] = 1;
|
env->xdf1.rchg[line1 + ptr - 1] = 1;
|
||||||
for (ptr = 0; ptr < count2; ptr++)
|
for (ptr = 0; ptr < count2; ptr++)
|
||||||
env->xdf2.rchg[line2 + ptr - 1] = 1;
|
env->xdf2.rchg[line2 + ptr - 1] = 1;
|
||||||
|
result = 0;
|
||||||
} else {
|
} else {
|
||||||
result = histogram_diff(xpp, env,
|
result = histogram_diff(xpp, env,
|
||||||
line1, lcs.begin1 - line1,
|
line1, lcs.begin1 - line1,
|
||||||
line2, lcs.begin2 - line2);
|
line2, lcs.begin2 - line2);
|
||||||
|
if (result)
|
||||||
|
goto cleanup;
|
||||||
result = histogram_diff(xpp, env,
|
result = histogram_diff(xpp, env,
|
||||||
lcs.end1 + 1, LINE_END(1) - lcs.end1,
|
lcs.end1 + 1, LINE_END(1) - lcs.end1,
|
||||||
lcs.end2 + 1, LINE_END(2) - lcs.end2);
|
lcs.end2 + 1, LINE_END(2) - lcs.end2);
|
||||||
result *= -1;
|
if (result)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue