SZEDER Gábor <szeder....@gmail.com> writes:

>> +    char *base = buf->buf + git_dir_len, *base2 = NULL;
>> +
>> +    if (ends_with(base, ".lock"))
>> +            base = base2 = xstrndup(base, strlen(base) - 5);
>
> Hm, this adds the magic number 5 and calls strlen(base) twice, because
> ends_with() calls strip_suffix(), which calls strlen().  Calling
> strip_suffix() directly would allow us to avoid the magic number and
> the second strlen():
>
>   size_t len;
>   if (strip_suffix(base, ".lock", &len))
>           base = base2 = xstrndup(base, len);

Makes sense, and is easy to squash in.

Reply via email to