summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-05-25 19:04:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-05-25 19:04:36 (GMT)
commitec04a275b495a7d786b49aeca2eef7f45fb00c48 (patch)
tree0f7b5613f0befd0c256f1fcbf68bef32bb031841 /refs.c
parentfca9e0013eeaad45bff38f66667d2791a1edc53f (diff)
parent654ad400c27653a138b028cdd35a09b0c69c7ef0 (diff)
downloadgit-ec04a275b495a7d786b49aeca2eef7f45fb00c48.zip
git-ec04a275b495a7d786b49aeca2eef7f45fb00c48.tar.gz
git-ec04a275b495a7d786b49aeca2eef7f45fb00c48.tar.bz2
Merge branch 'mh/ref-api'
Fixes a performance regression in the earlier series.
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index d6bdb47..010ed07 100644
--- a/refs.c
+++ b/refs.c
@@ -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;
}
/*