com php-src: Improve implementation of array_key_first( ) and array_key_last(): ext/standard/array. c

From: Date: Tue, 17 Jul 2018 09:53:06 +0000
Subject: com php-src: Improve implementation of array_key_first( ) and array_key_last(): ext/standard/array. c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102581@lists.php.net to get a copy of this message
Commit: 9f957fd303712b55370f8154de19ee15e2c1237a Author: Christoph M. Becker <cmbecker69@gmx.de> Tue, 17 Jul 2018 11:53:06 +0200 Parents: 50516a6e1f357f63324ec76e26623f2a7185bd4f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9f957fd303712b55370f8154de19ee15e2c1237a Log: Improve implementation of array_key_first() and array_key_last() Firstly, we must not separate the $stack argument for performance reasons. Secondly, we prefer Z_ARRVAL_P over HASH_OF to clarify our intention. Thanks to Nikita, for catching these issues! Changed paths: M ext/standard/array.c Diff: diff --git a/ext/standard/array.c b/ext/standard/array.c index 82e0833..ec402ea 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3970,10 +3970,10 @@ PHP_FUNCTION(array_key_first) zval *stack; /* Input stack */ ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY_EX(stack, 0, 1) + Z_PARAM_ARRAY(stack) ZEND_PARSE_PARAMETERS_END(); - HashTable *target_hash = HASH_OF(stack); + HashTable *target_hash = Z_ARRVAL_P (stack); HashPosition pos = 0; zend_hash_get_current_key_zval_ex(target_hash, return_value, &pos); } @@ -3987,10 +3987,10 @@ PHP_FUNCTION(array_key_last) HashPosition pos; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY_EX(stack, 0, 1) + Z_PARAM_ARRAY(stack) ZEND_PARSE_PARAMETERS_END(); - HashTable *target_hash = HASH_OF(stack); + HashTable *target_hash = Z_ARRVAL_P (stack); zend_hash_internal_pointer_end_ex(target_hash, &pos); zend_hash_get_current_key_zval_ex(target_hash, return_value, &pos); }

« previous php.cvs (#102581) next »