From: Mike Hommey Date: Sat, 28 Feb 2009 22:44:01 GMT Subject: Re: [PATCH] import memmem() with linear complexity from Gnulib Message-ID: <20090228224401.GA27262@glandium.org> In-Reply-To: <1235848615.7043.30.camel@ubuntu.ubuntu-domain> 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 > < #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 > --- > 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