[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: STREQ in dfa.c
From: |
Jim Meyering |
Subject: |
Re: STREQ in dfa.c |
Date: |
Sat, 31 Dec 2011 19:38:14 +0100 |
Aharon Robbins wrote:
>> From: Jim Meyering <address@hidden>
...
>> address@hidden wrote:
>>
>> > There are not a lot of uses of STREQ in dfa.c. I'd be happy if you
>> > expanded the macro there.
>>
>> Sorry, but that would be a step backwards.
>> I find that direct use of strcmp is markedly less readable
>> when the result is used as a boolean.
>
> Interesting. I'd rather read
>
> strcmp(x, y) == 0
> and
> strcmp(x, y) != 0
I find these to be more readable/maintainable:
STREQ (x, y)
! STREQ (x, y)
We're comparing x and y after all.
Why should we compare anything to 0?
In addition, using less syntax is better.
> I am violently opposed to
>
> ! strcmp(x, y)
>
> This moves into the realm of individual tastes...
>
>> > Gawk's STREQ checks *a == *b before calling
>> > strcmp, which is an OOOOLLLLDDDD speed hack from the PDP-11 / Vax
>> > days. I should probably get rid of it.
>>
>> Good idea.
>
> If I do I will just go to using straight calls to strcmp/strncmp,
> but per your email, I won't mess with dfa.c. Some of the gawk code
> already has direct calls to strcmp so I may as well make things
> consistent.