Wrong patch file.. re-attaching. --- Brad LaFountain <[EMAIL PROTECTED]> wrote: > Along with fixing this bugs (16063 and 16068) I signifintly increased the > preformance of array_pop and array_shift. > > Here are some times on a 1.2ghz athlon. > <? > $t = array_fill(0, $size, "test"); > for($i = 0;$i < $size;$i++) > array_pop($t); > ?> > > Before: > $size = 2000; //1.633s > $size = 4000; //8.942s > $size = 6000; //24.005s > $size = 10000; //1m13.986s > > After: > $size = 2000; //0.050s > $size = 4000; //0.060s > $size = 6000; //0.081s > $size = 10000; //0.090s > > I still would like to see the functions array_unshift, array_splice and > array_pad looked into to increase preformance too. > > I thought i had karma but it seems i don't. So can someone ither give me the > karma or patch it themselves. > > -brad > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Health - Feel better, live better > http://health.yahoo.com> Index: ext/standard/array.c > =================================================================== > RCS file: /repository/php4/ext/standard/array.c,v > retrieving revision 1.172 > diff -u -r1.172 array.c > --- ext/standard/array.c 8 Jul 2002 07:33:22 -0000 1.172 > +++ ext/standard/array.c 30 Jul 2002 07:10:45 -0000 > @@ -1661,8 +1661,9 @@ > 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 */ > + **val; /* Value to be popped */ > + 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 @@ > 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); > } > /* }}} */ > > @@ -1747,7 +1746,8 @@ > } > > /* Use splice to insert the elements at the beginning. Destroy old > - hashtable and replace it with new one */ > + hashtable and replace it with new one */ > + zend_hash_insert > new_hash = php_splice(Z_ARRVAL_P(stack), 0, 0, &args[1], argc-1, NULL); > zend_hash_destroy(Z_ARRVAL_P(stack)); > efree(Z_ARRVAL_P(stack)); > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php
__________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com
Index: ext/standard/array.c =================================================================== RCS file: /repository/php4/ext/standard/array.c,v retrieving revision 1.172 diff -u -r1.172 array.c --- ext/standard/array.c 8 Jul 2002 07:33:22 -0000 1.172 +++ ext/standard/array.c 30 Jul 2002 07:13:34 -0000 @@ -1661,8 +1661,9 @@ 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 */ + **val; /* Value to be popped */ + 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 @@ 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); } /* }}} */
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php