From: Junio C Hamano Date: Tue, 05 Feb 2008 07:00:43 GMT Subject: Re: [PATCH RESEND] Avoid a useless prefix lookup in strbuf_expand() Message-ID: <7vtzknga5g.fsf@gitster.siamese.dyndns.org> In-Reply-To: <1201950593-6119-1-git-send-email-mcostalba@gmail.com> Marco Costalba writes: > Currently the --prett=format prefix is looked up in a > ... > diff --git a/pretty.c b/pretty.c > index b987ff2..64ead65 100644 > --- a/pretty.c > +++ b/pretty.c > @@ -282,16 +282,18 @@ static char *logmsg_reencode(const struct commit *commit, > return out; > } > > -static void format_person_part(struct strbuf *sb, char part, > +/* returns placeholder length or 0 if placeholder is not known */ > +static size_t format_person_part(struct strbuf *sb, char part, > const char *msg, int len) > { > - int start, end, tz = 0; > - unsigned long date; > + int start, end, tz = 0, end_of_data; > + unsigned long date = 0; > char *ep; > > - /* parse name */ > + /* advance 'end' to point to email start delimiter */ > for (end = 0; end < len && msg[end] != '<'; end++) > ; /* do nothing */ > + Another thing I noticed is that --pretty='format:%an %ae %at' would end up running this function three times. Perhaps it is worth memoizing the result in format_commit_context while you are at it?