Skip to content

Commit d4e60a1

Browse files
committed
Avoid code duplication
1 parent b1864b0 commit d4e60a1

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

ext/standard/array.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,14 +3100,10 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H
31003100
p = in_hash->arData + idx;
31013101
if (Z_TYPE(p->val) == IS_UNDEF) continue;
31023102
pos2++;
3103-
if (p->key == NULL) {
3104-
zend_hash_del_bucket(in_hash, p);
3103+
if (p->key && in_hash == &EG(symbol_table)) {
3104+
zend_delete_global_variable(p->key);
31053105
} else {
3106-
if (in_hash == &EG(symbol_table)) {
3107-
zend_delete_global_variable(p->key);
3108-
} else {
3109-
zend_hash_del_bucket(in_hash, p);
3110-
}
3106+
zend_hash_del_bucket(in_hash, p);
31113107
}
31123108
}
31133109
}
@@ -3231,12 +3227,8 @@ PHP_FUNCTION(array_pop)
32313227
}
32323228

32333229
/* Delete the last value */
3234-
if (p->key) {
3235-
if (Z_ARRVAL_P(stack) == &EG(symbol_table)) {
3236-
zend_delete_global_variable(p->key);
3237-
} else {
3238-
zend_hash_del_bucket(Z_ARRVAL_P(stack), p);
3239-
}
3230+
if (p->key && Z_ARRVAL_P(stack) == &EG(symbol_table)) {
3231+
zend_delete_global_variable(p->key);
32403232
} else {
32413233
zend_hash_del_bucket(Z_ARRVAL_P(stack), p);
32423234
}
@@ -3281,12 +3273,8 @@ PHP_FUNCTION(array_shift)
32813273
ZVAL_COPY_DEREF(return_value, val);
32823274

32833275
/* Delete the first value */
3284-
if (p->key) {
3285-
if (Z_ARRVAL_P(stack) == &EG(symbol_table)) {
3286-
zend_delete_global_variable(p->key);
3287-
} else {
3288-
zend_hash_del_bucket(Z_ARRVAL_P(stack), p);
3289-
}
3276+
if (p->key && Z_ARRVAL_P(stack) == &EG(symbol_table)) {
3277+
zend_delete_global_variable(p->key);
32903278
} else {
32913279
zend_hash_del_bucket(Z_ARRVAL_P(stack), p);
32923280
}

0 commit comments

Comments
 (0)