com php-src: Avoid code duplication: ext/standard/array.c

From: Date: Mon, 23 Jul 2018 13:53:44 +0000
Subject: com php-src: Avoid code duplication: ext/standard/array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102653@lists.php.net to get a copy of this message
Commit: d4e60a1ffdaa63f4993d8c4c23eba998a8abc555 Author: Dmitry Stogov <dmitry@zend.com> Mon, 23 Jul 2018 16:53:44 +0300 Parents: b1864b017860b69f0b20a75fad790c9ab7a4fd1c Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d4e60a1ffdaa63f4993d8c4c23eba998a8abc555 Log: Avoid code duplication Changed paths: M ext/standard/array.c Diff: diff --git a/ext/standard/array.c b/ext/standard/array.c index ec402ea..25e8520 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3100,14 +3100,10 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H p = in_hash->arData + idx; if (Z_TYPE(p->val) == IS_UNDEF) continue; pos2++; - if (p->key == NULL) { - zend_hash_del_bucket(in_hash, p); + if (p->key && in_hash == &EG(symbol_table)) { + zend_delete_global_variable(p->key); } else { - if (in_hash == &EG(symbol_table)) { - zend_delete_global_variable(p->key); - } else { - zend_hash_del_bucket(in_hash, p); - } + zend_hash_del_bucket(in_hash, p); } } } @@ -3231,12 +3227,8 @@ PHP_FUNCTION(array_pop) } /* Delete the last value */ - if (p->key) { - if (Z_ARRVAL_P(stack) == &EG(symbol_table)) { - zend_delete_global_variable(p->key); - } else { - zend_hash_del_bucket(Z_ARRVAL_P(stack), p); - } + if (p->key && Z_ARRVAL_P(stack) == &EG(symbol_table)) { + zend_delete_global_variable(p->key); } else { zend_hash_del_bucket(Z_ARRVAL_P(stack), p); } @@ -3281,12 +3273,8 @@ PHP_FUNCTION(array_shift) ZVAL_COPY_DEREF(return_value, val); /* Delete the first value */ - if (p->key) { - if (Z_ARRVAL_P(stack) == &EG(symbol_table)) { - zend_delete_global_variable(p->key); - } else { - zend_hash_del_bucket(Z_ARRVAL_P(stack), p); - } + if (p->key && Z_ARRVAL_P(stack) == &EG(symbol_table)) { + zend_delete_global_variable(p->key); } else { zend_hash_del_bucket(Z_ARRVAL_P(stack), p); }

« previous php.cvs (#102653) next »