about summary refs log tree commit diff
path: root/src/string/strstr.c
Commit message (Collapse)AuthorAgeFilesLines
* optimize two-way strstr and memmem bad character shiftRich Felker2018-11-081-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.
* remove commented-out debug printf from strstrRich Felker2018-11-021-1/+0
| | | | this was leftover from before the initial commit.
* fix spuriously slow check in twoway strstr/memmem coresRich Felker2018-11-021-1/+1
| | | | | mem0 && mem && ... is redundant since mem can only be nonzero when mem0 is nonzero.
* fix false negatives with periodic needles in strstr, wcsstr, and memmemRich Felker2014-04-181-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.
* include cleanups: remove unused headers and add feature test macrosSzabolcs Nagy2013-12-121-1/+0
|
* remove unused but buggy code from strstr.cRich Felker2012-08-111-10/+0
|
* fix all implicit conversion between signed/unsigned pointersRich Felker2011-03-251-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.
* initial check-in, version 0.5.0 v0.5.0Rich Felker2011-02-121-0/+166