This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: [PATCH] Improve strncpy performance further
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "Wilco Dijkstra" <wdijkstr at arm dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Wed, 15 Apr 2015 11:27:23 -0700 (PDT)
- Subject: RE: [PATCH] Improve strncpy performance further
- Authentication-results: sourceware.org; auth=none
- References: <001801d02b72$6ce0c3c0$46a24b40$ at com> <20150108185812 dot 285782C3BF6 at topped-with-meat dot com> <000501d0529f$362b9d10$a282d730$ at com>
> > > Roland McGrath:
> > > Has to be __strnlen.
> >
> > Good point, so it becomes:
> >
> > - return s;
> > + size_t size = __strnlen (s2, n);
> > + if (size != n)
> > + memset (s1 + size, '\0', n - size);
> > + return memcpy (s1, s2, size);
>
> OK for trunk with __strnlen?
Style and whatnot is fine now. I have no opinion one way or the other
about this being an appropriate performance change.