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: [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


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