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

Re: [PATCH] pack-objects: use strcspn(3) in name_cmp_len()

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2023, 22:35 UTC
Message-ID
<xmqqr0v22zio.fsf@gitster.g>
In-Reply-To
<230205.86357j95wj.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 5 quoted lines
> I wonder if this name_cmp_len() is worth keeping at all. If all we're
> doing is wrapping strcspn() (which b.t.w, seem to be less "open-coding"
> and just that it wasn't known to the original author in 5d4a6003354
> (Make git-pack-objects a builtin, 2006-08-03)), then just inlining that
> in the two name_cmp_len() invocations would be better, or maybe:

Even if the stop candidate bytes were a constant, or if there were only a single callsite, I am not sure if it is a good idea, simply because with this

> 	strcspn(..., object_reject);

or with a literal "\n/" to make it easier to see where in the string we are stopping, it is hard without named function to tell what length we are computing.

The function being file-scope static, decent compilers hopefully would inline the calls by two callers.

Previous: Ævar Arnfjörð Bjarmason
Message 3 of 3 in “pack-objects: use strcspn(3) in name_cmp_len()”
  1. pack-objects: use strcspn(3) in name_cmp_len()René Scharfe, Feb 5, 2023
  2. Ævar Arnfjörð BjarmasonFeb 5, 2023
  3. Junio C HamanoFeb 6, 2023

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.