git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH RESEND] Avoid a useless prefix lookup in strbuf_expand()

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 5, 2008, 07:00 UTC
Message-ID
<7vtzknga5g.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1201950593-6119-1-git-send-email-mcostalba@gmail.com>
Marco Costalba <mcostalba@gmail.com> writes:
Show 26 quoted lines
> 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?

Previous: Marco CostalbaNext: Marco Costalba
Message 4 of 5 in “Avoid a useless prefix lookup in strbuf_expand()”
  1. Avoid a useless prefix lookup in strbuf_expand()Marco Costalba, Feb 2, 2008
  2. Junio C HamanoFeb 3, 2008
  3. Marco CostalbaFeb 3, 2008
  4. Junio C HamanoFeb 5, 2008
  5. Marco CostalbaFeb 5, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.