]> granicus.if.org Git - php/commitdiff
rehash only in case something is changed.
authorAndrey Hristov <andrey@php.net>
Sat, 22 Feb 2003 10:54:26 +0000 (10:54 +0000)
committerAndrey Hristov <andrey@php.net>
Sat, 22 Feb 2003 10:54:26 +0000 (10:54 +0000)
#lowers the execution time in half on my machine on array with 1000 elements
#with nonscalar keys. Maybe it can be optimized further.

ext/standard/array.c

index 32edd74c1f9f79e850265115810500245af1fa75..cf4f1889cf88bbb7bbfb2d513972a3e8656d3fe4 100644 (file)
@@ -1866,7 +1866,9 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
                        p = p->pListNext;
                }
                Z_ARRVAL_PP(stack)->nNextFreeElement = k;
-               zend_hash_rehash(Z_ARRVAL_PP(stack));
+               if (k) {
+                       zend_hash_rehash(Z_ARRVAL_PP(stack));
+               }
        } else if (!key_len) {
                Z_ARRVAL_PP(stack)->nNextFreeElement = Z_ARRVAL_PP(stack)->nNextFreeElement - 1;
        }