https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108886
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonny Grant from comment #4) > It sounds like you know the implementation really well. I wrote it. > I doubt all uses of std::string are performance intensive. Just because some aren't, doesn't mean we can ignore the ones that are. > For performance > critical code identified by a profiler I just re-write that function in C. No. std::string is probably the most widely used vocabulary type in the entire C++ standard library, and "just use C instead" is utterly unacceptable as a response to performance concerns. > Usually graphics code. > > There is what might be a performance issue, I don't know if anyone has > measured, _M_construct() appears to copy copies byte by byte in > basic_string.tcc:177 rather than using an optimized memcpy(). I've not > measured this myself. You can't use memcpy from an input iterator, the data to be copied isn't contiguous in memory.