mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 05:28:34 +00:00
treebuilder: insert sorted
By inserting in the right position, we can keep the vector sorted, making entry insertion almost twice as fast.
This commit is contained in:
parent
281da0043c
commit
2c11d2eeb5
@ -460,7 +460,7 @@ static int append_entry(
|
||||
git_oid_cpy(&entry->oid, id);
|
||||
entry->attr = (uint16_t)filemode;
|
||||
|
||||
if (git_vector_insert(&bld->entries, entry) < 0) {
|
||||
if (git_vector_insert_sorted(&bld->entries, entry, NULL) < 0) {
|
||||
git__free(entry);
|
||||
return -1;
|
||||
}
|
||||
@ -671,7 +671,7 @@ int git_treebuilder_insert(
|
||||
entry = alloc_entry(filename);
|
||||
GITERR_CHECK_ALLOC(entry);
|
||||
|
||||
if (git_vector_insert(&bld->entries, entry) < 0) {
|
||||
if (git_vector_insert_sorted(&bld->entries, entry, NULL) < 0) {
|
||||
git__free(entry);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user