This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: [PATCH][PING] Improve stpncpy performance
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: 'Ondřej Bílka' <neleai at seznam dot cz>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 9 Jul 2015 16:02:26 +0100
- Subject: RE: [PATCH][PING] Improve stpncpy performance
- Authentication-results: sourceware.org; auth=none
- References: <000301d0b7df$02f253d0$08d6fb70$ at com> <20150709110655 dot GA29253 at domone>
> 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