diff options
author | Xinchen Hui <laruence@php.net> | 2015-01-15 18:41:25 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2015-01-15 18:41:25 +0800 |
commit | 9aac41753b2478fbba69a89332b77f62d142f35c (patch) | |
tree | 3d6175c7f1f7f3e32c25ce3c1dc9ef2669774fbc | |
parent | 1af91d944aabad42014c0e34cbf54e89a87590b1 (diff) | |
download | php-git-9aac41753b2478fbba69a89332b77f62d142f35c.tar.gz |
Save one condition
-rw-r--r-- | ext/standard/array.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 0b50cf3cb0..fcf901cc5a 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2408,13 +2408,14 @@ PHP_FUNCTION(array_slice) length = num_in - offset; } - /* Initialize returned array */ - array_init_size(return_value, length > 0 ? (uint32_t)length : 0); - if (length <= 0) { + array_init(return_value); return; } + /* Initialize returned array */ + array_init_size(return_value, (uint32_t)length); + /* Start at the beginning and go until we hit offset */ pos = 0; ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_key, string_key, entry) { |