Re: [PATCH v4 5/8] trailer: clarify failure modes in parse_trailer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 20, 2016, 22:14 UTC
- Message-ID
- <xmqqvawmekhk.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAGZ79kYi=+JUqmFyR+Xapwy2bLHtmCX7ZFxd9bGkNHS5tjEdOw@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 13 quoted lines
>> +static int find_separator(const char *line)
>> +{
>> + const char *c;
>> + for (c = line; ; c++) {
>> + if (!*c || *c == '\n')
>> + return -1;
>> + if (*c == '=' || strchr(separators, *c))
>> + return c - line;
>> + }
>
> I was about to suggest this function can be simplified and maybe
> even inlined by the use of strspn or strcspn, but I think manual
> processing of the string is fine, too, as it would not really be shorter.Hmm, I fear that iterating over a line one-byte-at-a-time and running strchr(separators, *c) on it for each byte has a performance implication over running a single call to strcspn(line, separators).