fetch-pack: sort incoming heads list earlier
authorJeff King <peff@peff.net>
Thu, 24 May 2012 06:04:51 +0000 (02:04 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 24 May 2012 17:02:37 +0000 (10:02 -0700)
Commit 4435968 started sorting heads fed to fetch-pack so
that later commits could use more optimized algorithms;
commit 7db8d53 switched the remove_duplicates function to
such an algorithm.

Of course, the sorting is more effective if you do it
_before_ the algorithm in question.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch-pack.c
index 8a724739ba73876a0a182e80b183750627339294..b18ba05bbeeb645bbda15de8272056df17a2bea2 100644 (file)
@@ -1082,8 +1082,8 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
        }
 
        if (heads && nr_heads) {
-               nr_heads = remove_duplicates(nr_heads, heads);
                qsort(heads, nr_heads, sizeof(*heads), compare_heads);
+               nr_heads = remove_duplicates(nr_heads, heads);
        }
 
        if (!ref) {