Quote:Original post by T1Oracle
What if the "lazily" copied string goes out of scope?
link <-Slow STL string performance. I'm sure I found it somewhere else though, but this is all I have right now.
*edit* Also, I only use my class for STL maps and the printf feature, after that I usually convert it to a STL string. I'm most concerned about performance in the STL map since I use those heavily in my code.
If the lazily copied string goes out of scope, typically the copy gains control of the memory used to store the string.
This is a small implementation detail - copy-on-write is a tried and tested idiom for reducing wasted cpu usage and works very well.
If you are so concerned about speed, I suggest you use a hash table rather than std::map.