summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-08-21 18:30:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-08-25 17:27:52 (GMT)
commite8d1dfe639f71dc957c30c1eaa82a3ef0010cd8e (patch)
tree1bbf774206ef7766a568f19d855959fae88fb3c7 /sha1_name.c
parentd31f3ad23dd1aee3c3e1015a43b02b995c01a9a1 (diff)
downloadgit-e8d1dfe639f71dc957c30c1eaa82a3ef0010cd8e.zip
git-e8d1dfe639f71dc957c30c1eaa82a3ef0010cd8e.tar.gz
git-e8d1dfe639f71dc957c30c1eaa82a3ef0010cd8e.tar.bz2
sha1_name: avoid quadratic list insertion in handle_one_ref
Similar to 16445242 (fetch-pack: avoid quadratic list insertion in mark_complete), sort only after all refs are collected instead of while inserting. The result is the same, but it's more efficient that way. The difference will only be measurable in repositories with a large number of refs. Signed-off-by: Rene Scharfe <l.s.r@web.de> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 6fca869..e5f7951 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -835,7 +835,7 @@ static int handle_one_ref(const char *path,
}
if (object->type != OBJ_COMMIT)
return 0;
- commit_list_insert_by_date((struct commit *)object, list);
+ commit_list_insert((struct commit *)object, list);
return 0;
}
@@ -1377,6 +1377,7 @@ static int get_sha1_with_context_1(const char *name,
if (!only_to_die && namelen > 2 && name[1] == '/') {
struct commit_list *list = NULL;
for_each_ref(handle_one_ref, &list);
+ commit_list_sort_by_date(&list);
return get_sha1_oneline(name + 2, sha1, list);
}
if (namelen < 3 ||