bdiff: rearrange the "better longest match" code
This is primarily to make the code more managable and prepare for later
changes.
More specific assignments might also be slightly faster, even thought it also
might generate a bit more code.
--- a/mercurial/bdiff.c Tue Nov 08 18:37:33 2016 +0100
+++ b/mercurial/bdiff.c Tue Nov 08 18:37:33 2016 +0100
@@ -177,10 +177,20 @@
/* best match so far? we prefer matches closer
to the middle to balance recursion */
- if (k > mk || (k == mk && (i <= mi || i <= half))) {
+ if (k > mk) {
+ /* a longer match */
mi = i;
mj = j;
mk = k;
+ } else if (k == mk) {
+ if (i > mi && i <= half) {
+ /* same match but closer to half */
+ mi = i;
+ mj = j;
+ } else if (i == mi) {
+ /* same i but earlier j */
+ mj = j;
+ }
}
}
}