Re: [PATCH] import memmem() with linear complexity from Gnulib
From: Mike Hommey <hidden>
Date: 2016-06-15 22:46:18
On Sat, Feb 28, 2009 at 08:16:55PM +0100, René Scharfe wrote:
Gnulib and glibc have gained a memmem() implementation using the Two-Way algorithm, which needs constant space and linear time. Import it to compat/ in order to replace the simple quadratic implementation there. memmem.c and str-two-way.h are copied verbatim from the repository at git://git.savannah.gnu.org/gnulib.git, with the following changes to memmem.c to make it fit into git's build environment: 21,23c21 < #ifndef _LIBC < # include <config.h> < #endif --- > #include "../git-compat-util.h" 40c38 < memmem (const void *haystack_start, size_t haystack_len, --- > gitmemmem(const void *haystack_start, size_t haystack_len, Signed-off-by: Rene Scharfe <redacted> --- Makefile | 1 + compat/memmem.c | 103 +++++++++---- compat/str-two-way.h | 429 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 504 insertions(+), 29 deletions(-)
Seeing how much memmem is being used in the codebase, is it really worth? Mike