Skip to content

Commit

Permalink
Merge pull request #114 from Hojun-Cho/rwonly/qvector
Browse files Browse the repository at this point in the history
qvector performance improvement
  • Loading branch information
wolkykim authored May 15, 2024
2 parents 9734923 + 20d7435 commit 0ed15e9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/containers/qvector.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,13 +958,10 @@ static bool remove_at(qvector_t *vector, int index) {
}
}

int i;
for (i = index + 1; i < vector->num; i++) {
void *src = (unsigned char *)vector->data + i * vector->objsize;
void *dst = (unsigned char *)vector->data + (i - 1) * vector->objsize;

memcpy(dst, src, vector->objsize);
}
void *src = (unsigned char *)vector->data + (index + 1) * vector->objsize;
void *dst = (unsigned char *)vector->data + index * vector->objsize;
int size = (vector->num - (index + 1)) * vector->objsize;
memcpy(dst, src, size);

return true;
}
Expand Down

0 comments on commit 0ed15e9

Please sign in to comment.