Commit Graph

6 Commits

Author SHA1 Message Date
Ed Maste
88521634e9 libc: Use musl's O(n) memmem and strstr
It is O(n) in the length of the haystack (big) string, and has special
cases for short needle (little) strings, of one to four bytes, to avoid
excessive overhead.

There are a small set of nearly trivial cases where the startup overhead
of the musl implementation makes it slightly slower -- for example, a 31
byte needle that matches the beginning of the haystack.  It's faster for
non-trivial cases, and significantly so for inputs that trigger worst-
case behaviour of the previous implementation.  As an example, in my
tests a 16K needle that matches the end of a 64K haystack is nearly
2000x faster with this implementation.

Reviewed by:	bapt (earlier), ed (earlier)
Obtained from:	musl (snapshot at commit c718f9fc)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D2601
2017-03-18 00:51:39 +00:00
Ed Maste
16150352f5 memmem(3): empty little string matches the beginning of the big string
This function originated in glibc, and this matches their behaviour
(and NetBSD, OpenBSD, and musl).

An empty big string (arg "l") is handled by the existing
l_len < s_len test.

Reviewed by:	bapt, ngie
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D2657
2015-05-26 21:16:07 +00:00
Baptiste Daroussin
8fbf3d50e3 use .Mt to mark up email addresses consistently (part4)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:25:03 +00:00
Ruslan Ermilov
36c71f6ac1 Fix prototype. 2005-11-24 06:56:21 +00:00
Ruslan Ermilov
ca5137742a Fix up markup. 2005-11-18 11:54:14 +00:00
Andre Oppermann
6050c8fe05 Add the function memmem(3) as found in glibc and others.
It is the binary equivalent to strstr(3).

 void *memmem(const void *big, size_t big_len,
	const void *little, size_t little_len);

Submitted by:	Pascal Gloor <pascal.gloor at spale.com>
MFC after:	3 days
2005-08-25 18:26:58 +00:00