diff options
| author | Reeze Xia <reeze@php.net> | 2015-10-30 19:52:03 +0800 |
|---|---|---|
| committer | Reeze Xia <reeze@php.net> | 2015-10-30 19:52:03 +0800 |
| commit | 880965b95e25a9dfe976aa6bf905c408796c7a64 (patch) | |
| tree | 84f96fbae287c546f02e75b3f9c62f9d6e1bb1b7 | |
| parent | 9ccb432cab331e3905e4c746324d0bd6dc31286a (diff) | |
| parent | c4297a5a2949c11a8f49bc90a661ba74f2f03f03 (diff) | |
| download | php-git-880965b95e25a9dfe976aa6bf905c408796c7a64.tar.gz | |
Merge branch 'PHP-7.0'
* PHP-7.0:
This couldn't be false as it has been checked before
Use h parameter to avoid duplicate ht access of `array_combine()`
| -rw-r--r-- | ext/standard/array.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 88818fe78f..a327da84b0 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -163,7 +163,7 @@ static int php_array_key_compare(const void *a, const void *b) /* {{{ */ l2 = 0; } } - } else if (f->key) { + } else { if (s->key) { return zendi_smart_strcmp(f->key, s->key); } else { @@ -5474,17 +5474,17 @@ PHP_FUNCTION(array_chunk) Creates an array by using the elements of the first parameter as keys and the elements of the second as the corresponding values */ PHP_FUNCTION(array_combine) { - zval *values, *keys; + HashTable *values, *keys; uint32_t pos_values = 0; zval *entry_keys, *entry_values; int num_keys, num_values; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa", &keys, &values) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "hh", &keys, &values) == FAILURE) { return; } - num_keys = zend_hash_num_elements(Z_ARRVAL_P(keys)); - num_values = zend_hash_num_elements(Z_ARRVAL_P(values)); + num_keys = zend_hash_num_elements(keys); + num_values = zend_hash_num_elements(values); if (num_keys != num_values) { php_error_docref(NULL, E_WARNING, "Both parameters should have an equal number of elements"); @@ -5497,12 +5497,12 @@ PHP_FUNCTION(array_combine) return; } - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), entry_keys) { + ZEND_HASH_FOREACH_VAL(keys, entry_keys) { while (1) { - if (pos_values >= Z_ARRVAL_P(values)->nNumUsed) { + if (pos_values >= values->nNumUsed) { break; - } else if (Z_TYPE(Z_ARRVAL_P(values)->arData[pos_values].val) != IS_UNDEF) { - entry_values = &Z_ARRVAL_P(values)->arData[pos_values].val; + } else if (Z_TYPE(values->arData[pos_values].val) != IS_UNDEF) { + entry_values = &values->arData[pos_values].val; if (Z_TYPE_P(entry_keys) == IS_LONG) { entry_values = zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL_P(entry_keys), entry_values); |
