This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [GLIBC][PATCH v2] Remove strdup inlines
On Mon, 12 Dec 2016, Wilco Dijkstra wrote:
> this is premature micro optimization. Removing unnecessary string copies
> (why is strdup of a constant string a useful idiom that should be optimized?)
It's useful to strdup constant strings e.g. to ensure that a string in a
given context is always dynamically allocated, so that subsequent code can
free it without needing to know where that particular value came from at
runtime (if some code paths use a constant value, others use a value from
elsewhere). (That doesn't answer why it would be performance-relevant.)
--
Joseph S. Myers
joseph@codesourcery.com