> Have you double-checked the code g++ generates?  I should not be overly
> surprised if current versions don't actually do much copying unless
> required.

I know what you mean: "premature optimization is the root of all
evil". But here, it is just following standard practice as recommended
by all textbooks.

The standard <string> library can implement copy on write but it is
not mandatory and we should not rely on that behaviour. Also the
compiler may do some optimizations and remove some copies him-self but
should we rely on a particular compiler to do our job when it is so
"easy" to write efficient code?
When I have finished, I plan to do a time comparison on some scores I
have. The locations where strings are copied are really numerous and I
am not planning to remove all of them: I am not checking if we really
need 'string' as return type instead of 'const string&'. This could be
another patch...

Frédéric

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to