提交 6d6d06c9 编写于 作者: M Michael Haggerty 提交者: Junio C Hamano

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: NMichael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 28d3f214
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册