From: Junio C Hamano Date: Mon, 06 Feb 2023 22:35:27 GMT Subject: Re: [PATCH] pack-objects: use strcspn(3) in name_cmp_len() Message-ID: In-Reply-To: <230205.86357j95wj.gmgdl@evledraar.gmail.com> Ævar Arnfjörð Bjarmason writes: > 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.