diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2014-11-25 09:02:31 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-11-25 10:09:49 -0800 |
commit | 6d6d06c9012e96d74e9ea7aeeb6ce6dcd1a11b0f (patch) | |
tree | 65c6b627c8431a64db21e08073bb90b902918851 /builtin/remote.c | |
parent | 28d3f214d12af4a3d7e625faf4bb0af6c735fa8b (diff) | |
download | git-6d6d06c9012e96d74e9ea7aeeb6ce6dcd1a11b0f.tar.gz |
prune_remote(): sort delete_refs_list references en masse
Inserting items into a list in sorted order is O(N^2) whereas
appending them unsorted and then sorting the list all at once is
O(N lg N).
string_list_insert() also removes duplicates, and this change loses
that functionality. But the strings in this list, which ultimately
come from a for_each_ref() iteration, cannot contain duplicates.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/remote.c')
-rw-r--r-- | builtin/remote.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/remote.c b/builtin/remote.c index d5a5a1663b..7d5c8d2074 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1341,8 +1341,9 @@ static int prune_remote(const char *remote, int dry_run) const char *refname = states.stale.items[i].util; delete_refs[i] = refname; - string_list_insert(&delete_refs_list, refname); + string_list_append(&delete_refs_list, refname); } + sort_string_list(&delete_refs_list); if (!dry_run) { struct strbuf err = STRBUF_INIT; |