prefix_ref_iterator: break when we leave the prefix
commit157113c614034dc247e1aa6fb65448125f71f7ca
authorJeff King <peff@peff.net>
Wed, 13 Sep 2017 17:15:56 +0000 (13 19:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Sep 2017 06:19:07 +0000 (14 15:19 +0900)
tree64ac736c06763f297f74b4b172ae65985fa391ca
parent8738a8a4df9ee50112b5f5a757c58988166974d3
prefix_ref_iterator: break when we leave the prefix

If the underlying iterator is ordered, then `prefix_ref_iterator` can
stop as soon as it sees a refname that comes after the prefix. This
will rarely make a big difference now, because `ref_cache_iterator`
only iterates over the directory containing the prefix (and usually
the prefix will span a whole directory anyway). But if *hint, hint* a
future reference backend doesn't itself know where to stop the
iteration, then this optimization will be a big win.

Note that there is no guarantee that the underlying iterator doesn't
include output preceding the prefix, so we have to skip over any
unwanted references before we get to the ones that we want.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/iterator.c