mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-09 06:51:56 -05:00
Merge branch 'mh/ref-api' into next
Will merge to master. By Michael Haggerty * mh/ref-api: Avoid sorting if references are added to ref_cache in order
This commit is contained in:
6
refs.c
6
refs.c
@@ -278,6 +278,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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user