mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00
Make array_shift/array_pop work better.
This commit is contained in:
parent
2fb5e56123
commit
f7072fbf87
1 changed files with 5 additions and 10 deletions
|
@ -2571,6 +2571,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
|
||||||
{
|
{
|
||||||
zval *stack, /* Input stack */
|
zval *stack, /* Input stack */
|
||||||
**val; /* Value to be popped */
|
**val; /* Value to be popped */
|
||||||
|
HashTable *new_hash; /* New stack */
|
||||||
char *string_key;
|
char *string_key;
|
||||||
ulong num_key;
|
ulong num_key;
|
||||||
|
|
||||||
|
@ -2600,16 +2601,10 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
|
||||||
return_value->is_ref=0;
|
return_value->is_ref=0;
|
||||||
|
|
||||||
/* Delete the first or last value */
|
/* Delete the first or last value */
|
||||||
switch (zend_hash_get_current_key(stack->value.ht, &string_key, &num_key)) {
|
new_hash = _phpi_splice(stack->value.ht, (off_the_end) ? -1 : 0, 1, NULL, 0, NULL);
|
||||||
case HASH_KEY_IS_STRING:
|
zend_hash_destroy(stack->value.ht);
|
||||||
zend_hash_del(stack->value.ht, string_key, strlen(string_key)+1);
|
efree(stack->value.ht);
|
||||||
efree(string_key);
|
stack->value.ht = new_hash;
|
||||||
break;
|
|
||||||
|
|
||||||
case HASH_KEY_IS_LONG:
|
|
||||||
zend_hash_index_del(stack->value.ht, num_key);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue