iliaa Sun Jun 11 21:55:50 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/standard string.c
/php-src NEWS
Log:
Improved performance of the implode() function on associated arrays by
200-300%.
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.2&r2=1.445.2.14.2.3&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.445.2.14.2.2
php-src/ext/standard/string.c:1.445.2.14.2.3
--- php-src/ext/standard/string.c:1.445.2.14.2.2 Sat Jun 10 15:29:06 2006
+++ php-src/ext/standard/string.c Sun Jun 11 21:55:49 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.445.2.14.2.2 2006/06/10 15:29:06 iliaa Exp $ */
+/* $Id: string.c,v 1.445.2.14.2.3 2006/06/11 21:55:49 iliaa Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -894,11 +894,23 @@
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) &tmp,
&pos) == SUCCESS) {
if ((*tmp)->type != IS_STRING) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(*tmp);
+ if ((*tmp)->type == IS_OBJECT) {
+ int copy;
+ zval expr;
+ zend_make_printable_zval(*tmp, &expr, ©);
+ smart_str_appendl(&implstr, Z_STRVAL(expr),
Z_STRLEN(expr));
+ if (copy) {
+ zval_dtor(&expr);
+ }
+ goto next;
+ } else {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(*tmp);
+ }
}
smart_str_appendl(&implstr, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
+next:
if (++i != numelems) {
smart_str_appendl(&implstr, Z_STRVAL_P(delim),
Z_STRLEN_P(delim));
}
@@ -916,6 +928,7 @@
{
zval **arg1 = NULL, **arg2 = NULL, *delim, *arr;
int argc = ZEND_NUM_ARGS();
+ HashPosition pos;
if (argc < 1 || argc > 2 ||
zend_get_parameters_ex(argc, &arg1, &arg2) == FAILURE) {
@@ -936,12 +949,10 @@
arr = *arg1;
} else {
if (Z_TYPE_PP(arg1) == IS_ARRAY) {
- SEPARATE_ZVAL(arg1);
arr = *arg1;
convert_to_string_ex(arg2);
delim = *arg2;
} else if (Z_TYPE_PP(arg2) == IS_ARRAY) {
- SEPARATE_ZVAL(arg2);
arr = *arg2;
convert_to_string_ex(arg1);
delim = *arg1;
@@ -951,8 +962,12 @@
}
}
+ pos = Z_ARRVAL_P(arr)->pInternalPointer;
+
php_implode(delim, arr, return_value);
+ Z_ARRVAL_P(arr)->pInternalPointer = pos;
+
if (argc == 1) {
FREE_ZVAL(delim);
}
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.547.2.83&r2=1.2027.2.547.2.84&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.83 php-src/NEWS:1.2027.2.547.2.84
--- php-src/NEWS:1.2027.2.547.2.83 Sat Jun 10 15:29:06 2006
+++ php-src/NEWS Sun Jun 11 21:55:49 2006
@@ -1,6 +1,8 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2006, PHP 5.2.0
+- Improved performance of the implode() function on associated arrays by
+ 200-300%. (Ilia)
- Improved performance of str_replace() when doing 1 char to 1 char or 1 char
to many chars replacement by 30-40%. (Ilia)
- Added memory_get_peak_usage() function for retrieving peak memory usage of
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php