mirror of
https://github.com/git/git.git
synced 2024-11-01 06:47:52 +01:00
56384e61ea
When memmem() was imported from glibc 2.2 into compat/, an optimization was dropped in the process, in order to make the code smaller and simpler. It was OK because memmem() wasn't used in performance-critical code. Now the situation has changed and we can benefit from this optimization. The trick is to avoid calling memcmp() if the first character of the needle already doesn't match. Checking one character directly is much cheaper than the function call overhead. We keep the first character of the needle in the variable named point and the rest in the one named tail. The following commands were run in a Linux kernel repository and timed, the best of five results is shown: $ STRING='Ensure that the real time constraints are schedulable.' $ git log -S"$STRING" HEAD -- kernel/sched.c >/dev/null On Windows Vista x64, before: real 0m8.470s user 0m0.000s sys 0m0.000s And after the patch: real 0m1.887s user 0m0.000s sys 0m0.000s Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com> |
||
---|---|---|
.. | ||
fnmatch | ||
regex | ||
cygwin.c | ||
cygwin.h | ||
fopen.c | ||
hstrerror.c | ||
inet_ntop.c | ||
inet_pton.c | ||
memmem.c | ||
mingw.c | ||
mingw.h | ||
mkdtemp.c | ||
mmap.c | ||
pread.c | ||
qsort.c | ||
setenv.c | ||
snprintf.c | ||
strcasestr.c | ||
strlcpy.c | ||
strtoumax.c | ||
unsetenv.c | ||
win32.h | ||
winansi.c |