com php-src: Use zval_get_string in implode: ext/st andard/string.c
| From: | Nikita Popov | Date: | Wed, 28 May 2014 16:45:00 +0000 |
| Subject: | com php-src: Use zval_get_string in implode: ext/st andard/string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78617@lists.php.net to get a copy of this message | ||
Commit: 3831b39302bbe0757e830d6a76a2a9b9c4a8efc7
Author: Nikita Popov <nikic@php.net> Wed, 28 May 2014 18:45:00 +0200
Parents: bf5a59d281f5c799b4183746906779303c61296b
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3831b39302bbe0757e830d6a76a2a9b9c4a8efc7
Log:
Use zval_get_string in implode
Also get rid of separate case for IS_OBJECT - this is already
handled by the default branch.
Changed paths:
M ext/standard/string.c
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 674bd58..a600fc8 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1123,8 +1123,7 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC)
zval *tmp;
smart_str implstr = {0};
int numelems, i = 0;
- zval tmp_val;
- int str_len;
+ zend_string *str;
numelems = zend_hash_num_elements(Z_ARRVAL_P(arr));
@@ -1153,30 +1152,20 @@ again:
case IS_DOUBLE: {
char *stmp;
- str_len = spprintf(&stmp, 0, "%.*G", (int) EG(precision), Z_DVAL_P(tmp));
+ int str_len = spprintf(&stmp, 0, "%.*G", (int) EG(precision), Z_DVAL_P(tmp));
smart_str_appendl(&implstr, stmp, str_len);
efree(stmp);
}
break;
- case 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);
- }
- }
- break;
case IS_REFERENCE:
tmp = Z_REFVAL_P(tmp);
goto again;
+
default:
- ZVAL_DUP(&tmp_val, tmp);
- convert_to_string(&tmp_val);
- smart_str_appendl(&implstr, Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
- zval_dtor(&tmp_val);
+ str = zval_get_string(tmp);
+ smart_str_appendl(&implstr, str->val, str->len);
+ STR_RELEASE(str);
break;
}