return;
}
- if ((offset == 0) && (length >= num_in) &&
- HT_IS_PACKED(Z_ARRVAL_P(input)) &&
- HT_IS_WITHOUT_HOLES(Z_ARRVAL_P(input))) {
- /* No real slicing, and the keys will be 0..n-1, so just copy */
- ZVAL_COPY(return_value, input);
- 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 */