# HG changeset patch # User Matt Mackall # Date 2016-04-22 02:46:31 # Node ID 8bcda4c76820c620941a11a4802be0015d7ecb23 # Parent e868d8ee7c8f29abe50f6bbd48ac0f23f5a6d5fc bdiff: fold in shift calculation in normalize This just makes the code harder to read without any performance advantage. We're going to make the check here more complex, let's make it simpler first. diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -259,22 +259,18 @@ static int diff(struct line *a, int an, /* normalize the hunk list, try to push each hunk towards the end */ for (curr = base->next; curr; curr = curr->next) { struct hunk *next = curr->next; - int shift = 0; if (!next) break; if (curr->a2 == next->a1 || curr->b2 == next->b1) - while (curr->a2 + shift < an && curr->b2 + shift < bn - && !cmp(a + curr->a2 + shift, - b + curr->b2 + shift)) - shift++; - if (!shift) - continue; - curr->b2 += shift; - next->b1 += shift; - curr->a2 += shift; - next->a1 += shift; + while (curr->a2 < an && curr->b2 < bn + && !cmp(a + curr->a2, b + curr->b2)) { + curr->a2++; + next->a1++; + curr->b2++; + next->b1++; + } } for (curr = base->next; curr; curr = curr->next)