mirror of
https://github.com/php/php-src.git
synced 2024-11-25 10:54:15 +08:00
make substr_count() 30% when counting instances of 1 byte long strings.
This commit is contained in:
parent
eab2cbf494
commit
b9575ead72
@ -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))) {
|
||||
|
Loading…
Reference in New Issue
Block a user