coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] copy, dd: simplify and optimize NUL bytes detection


From: Paolo Bonzini
Subject: Re: [PATCH] copy, dd: simplify and optimize NUL bytes detection
Date: Thu, 22 Oct 2015 17:52:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


On 22/10/2015 17:47, Bernhard Voelker wrote:
>> Note the above does break early if non zero detected in first 16 bytes.
>>
>> Also I suspect the extra conditions involved in using longs
>> for just the first 16 bytes would outweigh the benefits?
>> I.E. the first simple loop probably breaks early, and if not
>> has the added benefit of "priming the pumps" for the subsequent memcmp().
> 
> what about spending some 16 bytes of memory and do the memcmp on the whole
> buffer?
> 
>   static unsigned char p[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
>   return 0 == memcmp (p, buf, bufsize);

memcmp has high setup costs, because the compiler doesn't know it as
well as memcpy, so no. :(

Nerd sniping at its best!

Paolo



reply via email to

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