Save one condition

This commit is contained in:
Xinchen Hui 2015-01-15 18:41:25 +08:00
parent 1af91d944a
commit 9aac41753b

View file

@ -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) {