On 04/09/2014 04:47 PM, Eric Blake wrote:
> On 04/09/2014 06:25 AM, Bernhard Voelker wrote:
>> I was wondering why strlen() showed up over 3M times when
>> running "rm -rf some-dir" - where "some-dir" contained 1M files.
>> This was shown by "ltrace -c ...".
>>
>> The attached avoids 2M strlen() invocations for this case.
>>
> 
>>  #include <dirent.h>
>> -#ifndef _D_EXACT_NAMLEN
>> -# define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name)
>> -#endif
> 
> Doesn't _D_EXACT_NAMLEN avoid a strlen() call on platforms where it is
> defined?
> 
> 
>>  
>> -                if ((p = fts_alloc (sp, dp->d_name,
>> -                                    _D_EXACT_NAMLEN (dp))) == NULL)
>> +                namlen = strlen (dp->d_name);
> 
> In other words, I think it still might sense to do:
> 
> namlen = _D_EXACT_NAMLEN (dp);
> 
> then use namlen everywhere else, rather than blindly calling strlen(),
> for the case where _D_EXACT_NAMLEN also shaves a call.

I've already pushed.
But you're correct, so please push an adjustment,
or I can handle it later.

thanks,
Pádraig.

Reply via email to