This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH][PING] Improve stpncpy performance


> Ondřej Bílka wrote:
>
> You don't have to use special case
> 
> if (size == n)
>   return dest;
> 
> as it should be handled by
> 
> return memset (dest, '\0', 0);
> 
> That could improve performance a bit if its rare case. That doesn't
> matter much as memset makes that function slow and it shouldn't be
> used in performance sensitive code.
> 
> Otherwise ok for me.

On the benchtests the extra if made a significant difference, particularly
since memset of 0 is relatively expensive as it is being regarded as a very
rare case. It seems it should be less likely than the benchtests indicate,
but we'd have to fix the benchtest first to use more realistic data.

Wilco



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]