]> git.ipfire.org Git - thirdparty/git.git/commit - remote.c
ref_remove_duplicates(): avoid redundant bisection
authorMichael Haggerty <mhagger@alum.mit.edu>
Wed, 30 Oct 2013 05:33:07 +0000 (06:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Oct 2013 21:16:41 +0000 (14:16 -0700)
commit09ea1f8e0e85dd65307b29219ef1f5a3958eb918
tree1a9b68e600ee6408c1926d675d2b28e6bf8f2239
parent37f0dcbdc1585dafd81c393aa750292e8634035d
ref_remove_duplicates(): avoid redundant bisection

The old code called string_list_lookup(), and if that failed called
string_list_insert(), thus doing the bisection search through the
string list twice in the latter code path.

Instead, just call string_list_insert() right away.  If an entry for
that peer reference name already existed, then its util pointer is
always non-NULL.

Of course this doesn't change the fact that the repeated
string_list_insert() calls make the function scale like O(N^2) if the
input reference list is not already approximately sorted.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c