coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: prefer STREQ_LEN and STRPREFIX over strncmp in all ca


From: Bernhard Voelker
Subject: Re: [PATCH] maint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases
Date: Tue, 17 Feb 2015 08:53:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 02/16/2015 01:31 PM, Pádraig Brady wrote:
> On 15/02/15 22:26, Bernhard Voelker wrote:
>> diff --git a/src/du.c b/src/du.c
>> index 65fc074..5c664f9 100644
>> --- a/src/du.c
>> +++ b/src/du.c
>> @@ -968,8 +968,7 @@ main (int argc, char **argv)
>>              {
>>                /* Ignore "posix-" prefix, for compatibility with ls.  */
>>                static char const posix_prefix[] = "posix-";
>> -              while (strncmp (time_style, posix_prefix, sizeof posix_prefix 
>> - 1)
>> -                     == 0)
>> +              while (STRPREFIX (time_style, posix_prefix))
>>                  time_style += sizeof posix_prefix - 1;
> 
> I think the only difference between STREQ_LEN() and STRPREFIX()
> is that the former is more efficient when len is available?
> Hence STREQ_LEN() could be used above too?

Good point - pushed with that adjustment:
http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=9f5dce8070

Thanks for the review.

Have a nice day,
Berny



reply via email to

[Prev in Thread] Current Thread [Next in Thread]