diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-06-17 12:06:33 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-06-17 12:06:33 +0300 |
commit | 8c8ad8f40ed9af2d95057a078dbaa844d072cb68 (patch) | |
tree | f9971ad812a9a4a6cbbe880df6cb3235af447104 /ext/pcre/php_pcre.c | |
parent | a0b3fd78031f7d5218f73e3c9d44460c600fa2e8 (diff) | |
download | php-git-8c8ad8f40ed9af2d95057a078dbaa844d072cb68.tar.gz |
Use better hash functions (reuse key and avoid hash value recalculation)
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r-- | ext/pcre/php_pcre.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 3420a09988..c3ceb44fea 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1395,10 +1395,13 @@ static int preg_replace_impl(zval *return_value, zval *regex, zval *replace, zva if ((result = php_replace_in_subject(regex, replace, subject_entry, limit_val, is_callable_replace, &replace_count)) != NULL) { if (!is_filter || replace_count > old_replace_count) { /* Add to return array */ + zval zv; + + ZVAL_STR(&zv, result); if (string_key) { - add_assoc_str_ex(return_value, string_key->val, string_key->len, result); + zend_hash_add_new(Z_ARRVAL_P(return_value), string_key, &zv); } else { - add_index_str(return_value, num_key, result); + zend_hash_index_add_new(Z_ARRVAL_P(return_value), num_key, &zv); } } else { zend_string_release(result); |