summaryrefslogtreecommitdiffstats
path: root/Vector.c
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-10-06 17:19:40 +0200
committercgzones <cgzones@googlemail.com>2020-10-07 12:59:55 +0200
commit164051354f11c0426e09e4fa09feeca7de92e619 (patch)
treeed5b79f222088b0502ad83facd79337d2316a17a /Vector.c
parent1704c29b90535286afde9a42982c6cacc2e94ae2 (diff)
Replace copy loop by memmove in Vector_insert
This is basically the same change like in Vector_take, just in the opposite direction.
Diffstat (limited to 'Vector.c')
-rw-r--r--Vector.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Vector.c b/Vector.c
index a606894d..3d4e6466 100644
--- a/Vector.c
+++ b/Vector.c
@@ -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++;

© 2014-2024 Faster IT GmbH | imprint | privacy policy