Re: [PATCH v2 02/21] prefix_ref_iterator: break when we leave the prefix

2017-09-21 Thread Stefan Beller
On Wed, Sep 20, 2017 at 9:59 PM, Jeff King wrote: >> But this compare function is not to order by the natural encoding order, >> but it's used to detect the '0' at the end of prefix, which orders >> before *any* unsigned char. > > It's not just detecting the "0". We care about the ordering overal

Re: [PATCH v2 02/21] prefix_ref_iterator: break when we leave the prefix

2017-09-21 Thread Michael Haggerty
On 09/20/2017 10:25 PM, Stefan Beller wrote: > On Mon, Sep 18, 2017 at 11:22 PM, Michael Haggerty > wrote: >> [...] >> +/* Return -1, 0, 1 if refname is before, inside, or after the prefix. */ >> +static int compare_prefix(const char *refname, const char *prefix) >> +{ >> + while (*prefix)

Re: [PATCH v2 02/21] prefix_ref_iterator: break when we leave the prefix

2017-09-20 Thread Jeff King
On Wed, Sep 20, 2017 at 01:25:43PM -0700, Stefan Beller wrote: > > +/* Return -1, 0, 1 if refname is before, inside, or after the prefix. */ > > +static int compare_prefix(const char *refname, const char *prefix) > > +{ > > + while (*prefix) { > > + if (*refname != *prefix) > >

Re: [PATCH v2 02/21] prefix_ref_iterator: break when we leave the prefix

2017-09-20 Thread Stefan Beller
On Mon, Sep 18, 2017 at 11:22 PM, Michael Haggerty wrote: > From: Jeff King > > 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

[PATCH v2 02/21] prefix_ref_iterator: break when we leave the prefix

2017-09-18 Thread Michael Haggerty
From: Jeff King 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 pre