com php-src: Use better hash functions (reuse key and avoid hash value recalculation): ext/pcre/php_pcre.c
| From: | Dmitry Stogov | Date: | Wed, 17 Jun 2015 09:06:33 +0000 |
| Subject: | com php-src: Use better hash functions (reuse key and avoid hash value recalculation): ext/pcre/php_pcre.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87311@lists.php.net to get a copy of this message | ||
Commit: 8c8ad8f40ed9af2d95057a078dbaa844d072cb68
Author: Dmitry Stogov <dmitry@zend.com> Wed, 17 Jun 2015 12:06:33 +0300
Parents: a0b3fd78031f7d5218f73e3c9d44460c600fa2e8
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8c8ad8f40ed9af2d95057a078dbaa844d072cb68
Log:
Use better hash functions (reuse key and avoid hash value recalculation)
Changed paths:
M ext/pcre/php_pcre.c
Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 3420a09..c3ceb44 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);