Replace copy loop by memmove in Vector_insert

This is basically the same change like in Vector_take,
just in the opposite direction.
This commit is contained in:
Benny Baumann 2020-10-06 17:19:40 +02:00 committed by cgzones
parent 1704c29b90
commit 164051354f

View File

@ -190,8 +190,8 @@ void Vector_insert(Vector* this, int idx, void* data_) {
Vector_checkArraySize(this);
//assert(this->array[this->items] == NULL);
for (int i = this->items; i > idx; i--) {
this->array[i] = this->array[i-1];
if(idx < this->items) {
memmove(&this->array[idx + 1], &this->array[idx], (this->items - idx) * sizeof(this->array[0]));
}
this->array[idx] = data;
this->items++;