Skip to content

Commit

Permalink
treebuilder: insert sorted
Browse files Browse the repository at this point in the history
By inserting in the right position, we can keep the vector sorted,
making entry insertion almost twice as fast.
  • Loading branch information
carlosmn committed Jun 9, 2014
1 parent 281da00 commit 2c11d2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2c11d2e

Please sign in to comment.