summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2005-06-19 16:31:51 +0000
committerIlia Alshanetsky <iliaa@php.net>2005-06-19 16:31:51 +0000
commitb9575ead72222d5456d84109f1cced29e8ee38c0 (patch)
treeeccaccb740c0e38417a129ee11e9d93e505be6b5
parenteab2cbf494231c3a450bd1c4f798861285241cd2 (diff)
downloadphp-git-b9575ead72222d5456d84109f1cced29e8ee38c0.tar.gz
make substr_count() 30% when counting instances of 1 byte long strings.
-rw-r--r--ext/standard/string.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 6b8b633c9b..31a6d7d295 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -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))) {