This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: [PATCH] Improve performance of strncpy
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: "'Florian Weimer'" <fweimer at redhat dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Wed, 10 Sep 2014 19:09:45 +0100
- Subject: RE: [PATCH] Improve performance of strncpy
- Authentication-results: sourceware.org; auth=none
- References: <001301cfcd0a$f0b62670$d2227350$ at com> <54108BB0 dot 90902 at redhat dot com>
> Florian Weimer wrote:
> On 09/10/2014 05:21 PM, Wilco Dijkstra wrote:
> > Yes, you're right, I timed it and there is actually little difference, while
> > the code is now even simpler. New version below (not attaching results in bad
> > characters due to various mail servers changing line endings).
> >
> > OK for commit?
>
> I think you could simplify it down to strnlen, memcpy, and memset.
I'll have a go at that in a follow-on patch. Something similar is possible with
strcpy and strncat which currently do byte-by-byte copies as well. Simplifying
the code is certainly a nice benefit besides the performance gain on longer
strings.
Wilco