iliaa Sun Jun 19 12:31:52 2005 EDT
Modified files:
/php-src/ext/standard string.c
Log:
make substr_count() 30% when counting instances of 1 byte long strings.
http://cvs.php.net/diff.php/php-src/ext/standard/string.c?r1=1.440&r2=1.441&ty=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.440 php-src/ext/standard/string.c:1.441
--- php-src/ext/standard/string.c:1.440 Sat Jun 18 14:23:12 2005
+++ php-src/ext/standard/string.c Sun Jun 19 12:31:51 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.440 2005/06/18 18:23:12 iliaa Exp $ */
+/* $Id: string.c,v 1.441 2005/06/19 16:31:51 iliaa Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -4463,11 +4463,10 @@
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))) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php