make substr_count() 30% when counting instances of 1 byte long strings.

This commit is contained in:
Ilia Alshanetsky 2005-06-19 16:31:51 +00:00
parent eab2cbf494
commit b9575ead72

View File

@ -4463,11 +4463,10 @@ PHP_FUNCTION(substr_count)
if (Z_STRLEN_PP(needle) == 1) {
cmp = Z_STRVAL_PP(needle)[0];
while (p < endp) {
if (*(p++) == cmp) {
count++;
}
while ((p = memchr(p, cmp, endp - p))) {
count++;
p++;
}
} else {
while ((p = php_memnstr(p, Z_STRVAL_PP(needle), Z_STRLEN_PP(needle), endp))) {