[Mesa-dev] [PATCH 11/12] glcpp: Create fast path hand-written scanner
Vladislav Egorov
vegorov180 at gmail.com
Sun Jan 8 23:30:56 UTC 2017
08.01.2017 17:11, Grazvydas Ignotas пишет:
> On Sat, Jan 7, 2017 at 9:02 PM, Vladislav Egorov <vegorov180 at gmail.com> wrote:
>> @@ -582,6 +609,333 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
>>
>> %%
>>
>> +static void
>> +glcpp_fast_skip_singleline_comment (glcpp_parser_t *parser, char **input)
>> +{
>> + /* Skip // */
>> + char *buf = *input + 2;
>> +
>> + while (true) {
>> + char ch = *buf;
>> + if (ch == '\r' || ch == '\n' || ch == '\0')
>> + break;
>> + buf++;
>> + }
> Looks like strpbrk() could be used here too?
> Also null char handling looks suspicious.
>
> Gražvydas
strpbrk() returns NULL if it encountered '\0', not '\0's position. It
seems that strcspn() is needed here. On my system GCC inlines it and
generates more or less the same code as loop/if variant, without
significant change in profiler, so it probably will be fine.
More information about the mesa-dev
mailing list