Small improvements to MLPPVector.

This commit is contained in:
Relintai 2023-02-05 09:50:03 +01:00
parent 8269406991
commit 9142592077

View File

@ -41,6 +41,12 @@ public:
--_size; --_size;
if (_size == 0) {
memfree(_data);
_data = NULL;
return;
}
for (int i = p_index; i < _size; i++) { for (int i = p_index; i < _size; i++) {
_data[i] = _data[i + 1]; _data[i] = _data[i + 1];
} }
@ -55,6 +61,12 @@ public:
ERR_FAIL_INDEX(p_index, _size); ERR_FAIL_INDEX(p_index, _size);
_size--; _size--;
if (_size == 0) {
memfree(_data);
_data = NULL;
return;
}
if (_size > p_index) { if (_size > p_index) {
_data[p_index] = _data[_size]; _data[p_index] = _data[_size];
} }
@ -94,7 +106,6 @@ public:
_FORCE_INLINE_ void clear() { resize(0); } _FORCE_INLINE_ void clear() { resize(0); }
_FORCE_INLINE_ void reset() { _FORCE_INLINE_ void reset() {
clear();
if (_data) { if (_data) {
memfree(_data); memfree(_data);
_data = NULL; _data = NULL;