com php-src: Prefer the macro we defined: main/php_variables .c

From: Date: Wed, 07 May 2014 09:06:27 +0000
Subject: com php-src: Prefer the macro we defined: main/php_variables .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-78172@lists.php.net to get a copy of this message
Commit: 2393000aeb6be8f7dd9e33585b96bb279f4f1eff Author: Xinchen Hui <laruence@php.net> Wed, 7 May 2014 17:06:27 +0800 Parents: e3a08096553df89b1c73eafdd9fd1ca2288cdce0 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2393000aeb6be8f7dd9e33585b96bb279f4f1eff Log: Prefer the macro we defined Changed paths: M main/php_variables.c Diff: diff --git a/main/php_variables.c b/main/php_variables.c index c67642c..30a8482 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -625,22 +625,19 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC) zval *src_entry, *dest_entry; zend_string *string_key; ulong num_key; - HashPosition pos; - int key_type; int globals_check = (dest == (&EG(symbol_table).ht)); - zend_hash_internal_pointer_reset_ex(src, &pos); - while ((src_entry = zend_hash_get_current_data_ex(src, &pos)) != NULL) { - key_type = zend_hash_get_current_key_ex(src, &string_key, &num_key, 0, &pos); + ZEND_HASH_FOREACH_KEY_VAL(src, num_key, string_key, src_entry) { if (Z_TYPE_P(src_entry) != IS_ARRAY - || (key_type == HASH_KEY_IS_STRING && (dest_entry = zend_hash_find(dest, string_key)) == NULL) - || (key_type == HASH_KEY_IS_LONG && (dest_entry = zend_hash_index_find(dest, num_key)) == NULL) + || (string_key && (dest_entry = zend_hash_find(dest, string_key)) == NULL) + || (string_key == NULL && (dest_entry = zend_hash_index_find(dest, num_key)) == NULL) || Z_TYPE_P(dest_entry) != IS_ARRAY) { if (Z_REFCOUNTED_P(src_entry)) { Z_ADDREF_P(src_entry); } - if (key_type == HASH_KEY_IS_STRING) { - if (!globals_check || string_key->len != sizeof("GLOBALS") || memcmp(string_key->val, "GLOBALS", sizeof("GLOBALS") - 1)) { + if (string_key) { + if (!globals_check || string_key->len != sizeof("GLOBALS") - 1 + || memcmp(string_key->val, "GLOBALS", sizeof("GLOBALS") - 1)) { zend_hash_update(dest, string_key, src_entry); } else if (Z_REFCOUNTED_P(src_entry)) { Z_DELREF_P(src_entry); @@ -652,8 +649,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC) SEPARATE_ZVAL(dest_entry); php_autoglobal_merge(Z_ARRVAL_P(dest_entry), Z_ARRVAL_P(src_entry) TSRMLS_CC); } - zend_hash_move_forward_ex(src, &pos); - } + } ZEND_HASH_FOREACH_END(); } /* }}} */

« previous php.cvs (#78172) next »