# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 2016-04-22 02:37:13
# Node ID e868d8ee7c8f29abe50f6bbd48ac0f23f5a6d5fc
# Parent  c05cc1b958488b15f494bad16e004d25416fd5ff

bdiff: unify duplicate normalize loops

We're about to make the while loop check more complicated, so let's simplify
first.

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -264,16 +264,11 @@ static int diff(struct line *a, int an, 
 		if (!next)
 			break;
 
-		if (curr->a2 == next->a1)
+		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++;
-		else if (curr->b2 == next->b1)
-			while (curr->b2 + shift < bn && curr->a2 + shift < an
-			       && !cmp(b + curr->b2 + shift,
-				       a + curr->a2 + shift))
-				shift++;
 		if (!shift)
 			continue;
 		curr->b2 += shift;