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.