summaryrefslogtreecommitdiff
path: root/src/string/strstr.c
AgeCommit message (Collapse)AuthorLines
2018-11-08optimize two-way strstr and memmem bad character shiftRich Felker-1/+1
first, the condition (mem && k < p) is redundant, because mem being nonzero implies the needle is periodic with period exactly p, in which case any byte that appears in the needle must appear in the last p bytes of the needle, bounding the shift (k) by p. second, the whole point of replacing the shift k by mem (=l-p) is to prevent shifting by less than mem when discarding the memory on shift, in which case linear time could not be guaranteed. but as written, the check also replaced shifts greater than mem by mem, reducing the benefit of the shift. there is no possible benefit to this reduction of the shift; since mem is being cleared, the full shift is valid and more optimal. so only replace the shift by mem when it would be less than mem.
2018-11-02remove commented-out debug printf from strstrRich Felker-1/+0
this was leftover from before the initial commit.
2018-11-02fix spuriously slow check in twoway strstr/memmem coresRich Felker-1/+1
mem0 && mem && ... is redundant since mem can only be nonzero when mem0 is nonzero.
2014-04-18fix false negatives with periodic needles in strstr, wcsstr, and memmemRich Felker-1/+1
in cases where the memorized match range from the right factor exceeded the length of the left factor, it was wrongly treated as a mismatch rather than a match. issue reported by Yves Bastide.
2013-12-12include cleanups: remove unused headers and add feature test macrosSzabolcs Nagy-1/+0
2012-08-11remove unused but buggy code from strstr.cRich Felker-10/+0
2011-03-25fix all implicit conversion between signed/unsigned pointersRich Felker-5/+5
sadly the C language does not specify any such implicit conversion, so this is not a matter of just fixing warnings (as gcc treats it) but actual errors. i would like to revisit a number of these changes and possibly revise the types used to reduce the number of casts required.
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+166