Permalink
Browse files

Merge branch 'mh/ref-api'

Fixes a performance regression in the earlier series.
  • Loading branch information...
2 parents fca9e00 + 654ad40 commit ec04a275b495a7d786b49aeca2eef7f45fb00c48 @gitster gitster committed May 25, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 refs.c
View
@@ -273,6 +273,12 @@ static void add_entry_to_dir(struct ref_dir *dir, struct ref_entry *entry)
{
ALLOC_GROW(dir->entries, dir->nr + 1, dir->alloc);
dir->entries[dir->nr++] = entry;
+ /* optimize for the case that entries are added in order */
+ if (dir->nr == 1 ||
+ (dir->nr == dir->sorted + 1 &&
+ strcmp(dir->entries[dir->nr - 2]->name,
+ dir->entries[dir->nr - 1]->name) < 0))
+ dir->sorted = dir->nr;
}
/*

0 comments on commit ec04a27

Please sign in to comment.