Re: [PATCH 3/3] send-pack: assign remote errors to each ref
- From
Jeff King <peff@peff.net>
- Date
- Nov 18, 2007, 05:00 UTC
- Message-ID
- <20071118050033.GA13097@sigill.intra.peff.net>
- In-Reply-To
- <7vwssgxir4.fsf@gitster.siamese.dyndns.org>
On Sat, Nov 17, 2007 at 08:47:11PM -0800, Junio C Hamano wrote:
Show 20 quoted lines
>>> + for (ref = refs; ref; ref = ref->next) {
>>> + const char *msg;
>>> + if (prefixcmp(line, ref->name))
>>> + continue;
>>> + msg = line + strlen(ref->name);
>>> + if (*msg++ != ' ')
>>> + continue;
>>> + ref->status = REF_STATUS_REMOTE_REJECT;
>>> + ref->error = xstrdup(msg);
>>> + ref->error[strlen(ref->error)-1] = '\0';
>>> + return ref;
>>> + }
>>> + return NULL;
>>> +}
> > It is actually _just_ prefixcmp. Or do you mean the strlen we call in
> > prefixcmp? If so, I think the right solution is to make prefixcmp
> > faster. :)
> I was referring to strlen(ref->name) taken for all refs during
> the loop. Micro-optimized one finds the end of refname on the
> "ng" line once before entering the loop.I don't see such a strlen, except in the implementation of prefixcmp, because we continue most of the time based on its result. If you have a false match on the prefixcmp (i.e., a prefix of another ref), you do an extra strlen.
But I don't think this is worth micro-optimizing.
-Peff