Browse Source

rehash only in case something is changed.

#lowers the execution time in half on my machine on array with 1000 elements
#with nonscalar keys. Maybe it can be optimized further.
PHP-5
Andrey Hristov 24 years ago
parent
commit
94040a28ce
  1. 4
      ext/standard/array.c

4
ext/standard/array.c

@ -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;
}

Loading…
Cancel
Save