cvs: php4 /ext/standard array.c

From: Date: Sat, 22 Feb 2003 13:55:12 +0000
Subject: cvs: php4 /ext/standard array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-19083@lists.php.net to get a copy of this message
andrey Sat Feb 22 08:55:12 2003 EDT Modified files: /php4/ext/standard array.c Log: additional speedup for array_shift(). No need to rehash if the removed element's key is not scalar and elements with scalar keys are already well numbered (sequentially from 0) for some reason. This is the case if the leading elements have no scalar indexes. Index: php4/ext/standard/array.c diff -u php4/ext/standard/array.c:1.221 php4/ext/standard/array.c:1.222 --- php4/ext/standard/array.c:1.221 Sat Feb 22 05:54:26 2003 +++ php4/ext/standard/array.c Sat Feb 22 08:55:11 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.221 2003/02/22 10:54:26 andrey Exp $ */ +/* $Id: array.c,v 1.222 2003/02/22 13:55:11 andrey Exp $ */ #include "php.h" #include "php_ini.h" @@ -1858,15 +1858,21 @@ /* If we did a shift... re-index like it did before */ if (!off_the_end) { int k = 0; + int should_rehash = 0; Bucket *p = Z_ARRVAL_PP(stack)->pListHead; while (p != NULL) { if (p->nKeyLength == 0) { - p->h = k++; + if (p->h != k) { + p->h = k++; + should_rehash = 1; + } else { + k++; + } } p = p->pListNext; } Z_ARRVAL_PP(stack)->nNextFreeElement = k; - if (k) { + if (should_rehash) { zend_hash_rehash(Z_ARRVAL_PP(stack)); } } else if (!key_len) {

« previous php.cvs (#19083) next »