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
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));
}
{
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) {
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;
}
}
+ pos = Z_ARRVAL_P(arr)->pInternalPointer;
+
php_implode(delim, arr, return_value);
+ Z_ARRVAL_P(arr)->pInternalPointer = pos;
+
if (argc == 1) {
FREE_ZVAL(delim);
}