[PATCH 1 of 6 STABLE V2] bdiff: unify duplicate normalize loops

Matt Mackall mpm at selenic.com
Mon Apr 25 22:10:17 UTC 2016


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1461292633 18000
#      Thu Apr 21 21:37:13 2016 -0500
# Branch stable
# Node ID 6bfbbd0aaf413b9a15ef491ba5f37eba3ece1caf
# Parent  38292b227debf6393dc1e2c6ff886f85f6673646
bdiff: unify duplicate normalize loops

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

diff -r 38292b227deb -r 6bfbbd0aaf41 mercurial/bdiff.c
--- a/mercurial/bdiff.c	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/bdiff.c	Thu Apr 21 21:37:13 2016 -0500
@@ -264,16 +264,11 @@
 		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;


More information about the Mercurial-devel mailing list