Merge pull request #32317 from KoBeWi/just_dont

Don't try to slice empty arrays
This commit is contained in:
Rémi Verschelde 2019-09-24 21:53:31 +02:00 committed by GitHub
commit dd3e17588e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,6 +240,9 @@ int Array::_clamp_index(int p_index) const {
Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound
Array new_arr; Array new_arr;
if (empty()) // Don't try to slice empty arrays.
return new_arr;
p_begin = Array::_fix_slice_index(p_begin, size(), -1); // can't start out of range p_begin = Array::_fix_slice_index(p_begin, size(), -1); // can't start out of range
p_end = Array::_fix_slice_index(p_end, size(), 0); p_end = Array::_fix_slice_index(p_end, size(), 0);