com php-src: Revert "Improve Hash foreach macros": Zend/zend_ hash.h ext/standard/array.c
| From: | Xinchen Hui | Date: | Tue, 23 Dec 2014 08:51:06 +0000 |
| Subject: | com php-src: Revert "Improve Hash foreach macros": Zend/zend_ hash.h ext/standard/array.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83834@lists.php.net to get a copy of this message | ||
Commit: 62e29736023e7d555736501cd05f31463394babb
Author: Xinchen Hui <laruence@php.net> Tue, 23 Dec 2014 03:51:06 -0500
Parents: 95bb0a0f7aec46cacf6a447ded1688e6c6ff4b62
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=62e29736023e7d555736501cd05f31463394babb
Log:
Revert "Improve Hash foreach macros"
This reverts commit 95bb0a0f7aec46cacf6a447ded1688e6c6ff4b62.
Changed paths:
M Zend/zend_hash.h
M ext/standard/array.c
Diff:
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index 5bdfa70..81b9332 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -678,11 +678,6 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable
*ht,
#define ZEND_HASH_FOREACH_STR_KEY(ht, _key) \
ZEND_HASH_FOREACH(ht, 0); \
_key = _p->key;
-
-#define ZEND_HASH_FOREACH_KEY_IND(ht, _h, _key) \
- ZEND_HASH_FOREACH(ht, 1); \
- _h = _p->h; \
- _key = _p->key;
#define ZEND_HASH_FOREACH_KEY(ht, _h, _key) \
ZEND_HASH_FOREACH(ht, 0); \
@@ -756,19 +751,6 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable
*ht,
_key = _p->key; \
_val = _z;
-#define ZEND_HASH_FOREACH_CURRENT_KEY(ht, _h, _key) \
- _h = _p->h; \
- _key = _p->key;
-
-#define ZEND_HASH_FOREACH_CURRENT_STR_KEY(ht, _key) \
- _key = _p->key;
-
-#define ZEND_HASH_FOREACH_CURRENT_NUM_KEY(ht, _h) \
- _h = _p->h;
-
-#define ZEND_HASH_FOREACH_CURRENT_VAL(ht, _val) \
- _val = _z;
-
#define ZEND_HASH_APPLY_PROTECTION(ht) \
((ht)->u.flags & HASH_FLAG_APPLY_PROTECTION)
diff --git a/ext/standard/array.c b/ext/standard/array.c
index b06b058..b9ccf5b 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1248,11 +1248,10 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int
behavior)
if (strict) {
zval res; /* comparison result */
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), entry) {
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
ZVAL_DEREF(entry);
fast_is_identical_function(&res, value, entry);
if (Z_TYPE(res) == IS_TRUE) {
- ZEND_HASH_FOREACH_CURRENT_KEY(Z_ARRVAL_P(array), num_idx, str_idx);
if (behavior == 0) {
RETURN_TRUE;
} else {
@@ -1266,9 +1265,8 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int
behavior)
}
} ZEND_HASH_FOREACH_END();
} else {
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), entry) {
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
if (fast_equal_check_function(value, entry)) {
- ZEND_HASH_FOREACH_CURRENT_KEY(Z_ARRVAL_P(array), num_idx, str_idx);
if (behavior == 0) {
RETURN_TRUE;
} else {
@@ -2676,6 +2674,8 @@ PHP_FUNCTION(array_keys)
{
zval *input, /* Input array */
*search_value = NULL, /* Value to search for */
+ *entry, /* An entry in the input array */
+ res, /* Result of comparison */
new_val; /* New value */
zend_bool strict = 0; /* do strict comparison */
zend_ulong num_idx;
@@ -2696,15 +2696,12 @@ PHP_FUNCTION(array_keys)
/* Initialize return array */
if (search_value != NULL) {
- zval *entry; /* An entry in the input array */
- zval res; /* Result of comparison */
array_init(return_value);
if (strict) {
- ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(input), entry) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(input), num_idx, str_idx, entry) {
fast_is_identical_function(&res, search_value, entry);
if (Z_TYPE(res) == IS_TRUE) {
- ZEND_HASH_FOREACH_CURRENT_KEY(Z_ARRVAL_P(input), num_idx, str_idx);
if (str_idx) {
ZVAL_STR_COPY(&new_val, str_idx);
} else {
@@ -2714,9 +2711,8 @@ PHP_FUNCTION(array_keys)
}
} ZEND_HASH_FOREACH_END();
} else {
- ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(input), entry) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(input), num_idx, str_idx, entry) {
if (fast_equal_check_function(search_value, entry)) {
- ZEND_HASH_FOREACH_CURRENT_KEY(Z_ARRVAL_P(input), num_idx, str_idx);
if (str_idx) {
ZVAL_STR_COPY(&new_val, str_idx);
} else {
@@ -2730,7 +2726,7 @@ PHP_FUNCTION(array_keys)
array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(input)));
/* Go through input array and add keys to the return array */
- ZEND_HASH_FOREACH_KEY_IND(Z_ARRVAL_P(input), num_idx, str_idx) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(input), num_idx, str_idx, entry) {
if (str_idx) {
ZVAL_STR_COPY(&new_val, str_idx);
} else {
@@ -2830,7 +2826,6 @@ zend_bool array_column_param_helper(zval *param,
return 0;
}
}
-/* }}} */
/* {{{ proto array array_column(array input, mixed column_key[, mixed index_key])
Return the values from a single column in the input array, identified by the
@@ -4048,10 +4043,9 @@ PHP_FUNCTION(array_diff)
/* copy all elements of first array that are not in exclude set */
array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL(args[0])));
- ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL(args[0]), value) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL(args[0]), idx, key, value) {
str = zval_get_string(value);
if (!zend_hash_exists(&exclude, str)) {
- ZEND_HASH_FOREACH_CURRENT_KEY(Z_ARRVAL(args[0]), idx, key);
if (key) {
zval_add_ref(value);
zend_hash_add_new(Z_ARRVAL_P(return_value), key, value);