# HG changeset patch # User Mads Kiilerich <mad...@unity3d.com> # Date 1478626653 -3600 # Tue Nov 08 18:37:33 2016 +0100 # Node ID 5bb26f29b1509520ca3af4c540775cab50b4d6c0 # Parent fbce612c9be26860338f6ba4ab5df819b6d79521 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. diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -177,10 +177,20 @@ static int longest_match(struct bdiff_li /* 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; + } } } } _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel