xdiff: optimise for no whitespace difference when ignoring whitespace.
In xdl_recmatch, do the memcmp to check if the two lines are equal before checking if whitespace flags are set. If the lines are identical, then there is no need to check if they differ only in whitespace. This makes the common case (there is no whitespace difference) faster. It costs the case where lines are the same length and contain whitespace differences, but the common case is more than 20% faster. Signed-off-by: Dylan Reid <dgreid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Dylan Reid committed
Jul 5, 2010 at 23:11 UTC
b4cf0f1784362fb4aa2383d8d5d829caa92ca3a0
1 file changed
+3
-1
xdiff/xutils.c
+3
-1
@@ -190,8 +190,10 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
190
{
191
int i1, i2;
192
193
+ if (s1 == s2 && !memcmp(l1, l2, s1))
194
+ return 1;
195
if (!(flags & XDF_WHITESPACE_FLAGS))
194
- return s1 == s2 && !memcmp(l1, l2, s1);
196
+ return 0;
197
198
i1 = 0;
199
i2 = 0;