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

Re: [PATCH 2/2] commit: don't check for space twice when looking for header

From
Jeff King <peff@peff.net>
Date
Feb 25, 2017, 21:51 UTC
Message-ID
<20170225215144.hb7huqmv3seaoaqf@sigill.intra.peff.net>
In-Reply-To
<6462e74c-1ee7-7ed0-0695-9889df803943@web.de>
On Sat, Feb 25, 2017 at 10:39:29PM +0100, René Scharfe wrote:
Show 7 quoted lines
> > > +		(len == 8 && !memcmp(field, "encoding", 8)));
> > 
> > Unrelated, but this could probably be spelled with a macro and strlen()
> > to avoid the magic numbers. It would probably be measurably slower for a
> > compiler which doesn't pre-compute strlen() on a string literal, though.
> 
> sizeof(string_constant) - 1 might be a better choice here than strlen().

Yeah. If you use a macro, that works. If it's an inline function you'd need strlen(). That's a tradeoff we've already made in skip_prefix_mem() and strip_suffix(), but it's not like we expect this list to grow much, so it may not be worth fussing with.

-Peff
Previous: René ScharfeNext: Jakub Narębski
Message 5 of 9 in “commit: be more precise when searching for headers”
  1. 1/2 commit: be more precise when searching for headersRené Scharfe, Feb 25, 2017
  2. 2/2 commit: don't check for space twice when looking for headerRené Scharfe, Feb 25, 2017
  3. Jeff KingFeb 25, 2017
  4. René ScharfeFeb 25, 2017
  5. Jeff KingFeb 25, 2017
  6. Jakub NarębskiFeb 27, 2017
  7. René ScharfeFeb 27, 2017
  8. Jeff KingFeb 25, 2017
  9. Junio C HamanoFeb 27, 2017

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.