diff options
author | Dmitry Stogov <dmitry@zend.com> | 2017-10-30 12:11:35 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2017-10-30 12:11:35 +0300 |
commit | fad75a54d4da2c9f399f3ee585b640b91a5cfe77 (patch) | |
tree | 35742a6ab69c37e125f53ee7f62ebd58b9122fd7 /ext/standard/array.c | |
parent | 8203a0668d1ec4d667336f8f3be469873d740911 (diff) | |
parent | e4a8b7a4b6f29fbaf18b6c4695b52114dff4b60c (diff) | |
download | php-git-fad75a54d4da2c9f399f3ee585b640b91a5cfe77.tar.gz |
Merge branch 'master' into rc_debug
* master: (26 commits)
Better fix for bug #75451 (Assertion fails while foreach on empty xpath query)
Catch with the latest AppVeyor unzip errors
Fixed type inference
Fix bug #75453 Incorrect reflection on ibase_connect and ibase_pconnect
Fix compiler warnings
We don't use a specific model for a MAKERNOTE so remove these checks that doesn't do anything anyway
Remove these old comments, as for the TODO, there is already a FR for this
Re-enable AppVeyor cache
make sure run-tests reports exit status upon prerequisite error
Remove implicit constants from test case
Fix invalid read in zend_use_undefined_constant()
Fix invalid read in mb_ord()
Remove --with-libmbfl configure option
Fixed bug #75451 (Assertion fails while foreach on empty xpath query)
Add tests for UConverter::getStandards()
convert spaces to tabs in ext/ftp/tests/server.inc
Add tests for ftp_rename
Fix bug #75434 Wrong reflection for mysqli_fetch_all function
Don't optimize input arrays with suffix holes
Fix bug #75307 Wrong reflection for openssl_open function
...
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r-- | ext/standard/array.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 61c6837586..1c1816765b 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3563,6 +3563,15 @@ PHP_FUNCTION(array_slice) return; } + if ((offset == 0) && (length >= num_in)) { + zend_array *ht = Z_ARRVAL_P(input); + if (preserve_keys || (HT_IS_PACKED(ht) && HT_IS_WITHOUT_HOLES(ht))) { + /* No real slicing, and the keys will match, so just copy */ + ZVAL_COPY(return_value, input); + return; + } + } + /* Initialize returned array */ array_init_size(return_value, (uint32_t)length); @@ -4013,6 +4022,7 @@ PHP_FUNCTION(array_values) zval *input, /* Input array */ *entry; /* An entry in the input array */ zend_array *arrval; + zend_long arrlen; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ARRAY(input) @@ -4021,12 +4031,14 @@ PHP_FUNCTION(array_values) arrval = Z_ARRVAL_P(input); /* Return empty input as is */ - if (!zend_hash_num_elements(arrval)) { + arrlen = zend_hash_num_elements(arrval); + if (!arrlen) { RETURN_ZVAL(input, 1, 0); } /* Return vector-like packed arrays as-is */ - if (HT_IS_PACKED(arrval) && HT_IS_WITHOUT_HOLES(arrval)) { + if (HT_IS_PACKED(arrval) && HT_IS_WITHOUT_HOLES(arrval) && + arrval->nNextFreeElement == arrlen) { RETURN_ZVAL(input, 1, 0); } |