Skip to content

Commit e19f520

Browse files
author
Scott MacVicar
committed
Optimisation for zend_memnstr when the needle is only a single character. (Patch by Michal Dziemianko - GSoC08)
1 parent 86a493f commit e19f520

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Zend/zend_operators.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ zend_memnstr(char *haystack, char *needle, int needle_len, char *end)
220220
char *p = haystack;
221221
char ne = needle[needle_len-1];
222222

223+
if (needle_len == 1) {
224+
return (char *)memchr(p, *needle, (end-p));
225+
}
226+
223227
end -= needle_len;
224228

225229
while (p <= end) {

0 commit comments

Comments
 (0)