]> granicus.if.org Git - php/commitdiff
fixed bugs 16063 and 16068
authorBrad LaFountain <rodif_bl@php.net>
Tue, 30 Jul 2002 22:54:12 +0000 (22:54 +0000)
committerBrad LaFountain <rodif_bl@php.net>
Tue, 30 Jul 2002 22:54:12 +0000 (22:54 +0000)
increased preformance of array_pop and array_shift

ext/standard/array.c

index 73a87fb011e251d5b18fa7e7050e249e99f743d1..e63dcfe04c79fddbff2c3f856c9156f76217b631 100644 (file)
@@ -1662,7 +1662,8 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
 {
        zval       **stack,                     /* Input stack */
                           **val;                       /* Value to be popped */
-       HashTable       *new_hash;              /* New stack */
+       char *key = NULL;
+       int key_len;
        
        /* Get the arguments and do error-checking */
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &stack) == FAILURE) {
@@ -1689,10 +1690,8 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
        INIT_PZVAL(return_value);
        
        /* Delete the first or last value */
-       new_hash = php_splice(Z_ARRVAL_PP(stack), (off_the_end) ? -1 : 0, 1, NULL, 0, NULL);
-       zend_hash_destroy(Z_ARRVAL_PP(stack));
-       efree(Z_ARRVAL_PP(stack));
-       Z_ARRVAL_PP(stack) = new_hash;
+       zend_hash_get_current_key_ex(Z_ARRVAL_PP(stack), &key, &key_len, &key_len, 0, NULL);
+       zend_hash_del_key_or_index(Z_ARRVAL_PP(stack), key, key_len, key_len, (key) ? HASH_DEL_KEY : HASH_DEL_INDEX);
 }
 /* }}} */