Skip to content

Commit

Permalink
Merge branch 'mh/ref-api'
Browse files Browse the repository at this point in the history
Fixes a performance regression in the earlier series.
  • Loading branch information
Junio C Hamano committed May 25, 2012
2 parents fca9e00 + 654ad40 commit ec04a27
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit ec04a27

Please sign in to comment.