]> granicus.if.org Git - php/commitdiff
Optimisation for zend_memnstr when the needle is only a single character. (Patch...
authorScott MacVicar <scottmac@php.net>
Mon, 21 Jul 2008 18:47:02 +0000 (18:47 +0000)
committerScott MacVicar <scottmac@php.net>
Mon, 21 Jul 2008 18:47:02 +0000 (18:47 +0000)
Zend/zend_operators.h

index fb19c0319dfe5eb32b32eb20077f2fa2000496e9..658e16c71dcf4d6e3103201690c863c937cd6ad6 100644 (file)
@@ -220,6 +220,10 @@ zend_memnstr(char *haystack, char *needle, int needle_len, char *end)
        char *p = haystack;
        char ne = needle[needle_len-1];
 
+       if (needle_len == 1) {
+               return (char *)memchr(p, *needle, (end-p));
+       }
+
        end -= needle_len;
 
        while (p <= end) {