------- Comment #1 from pcarlini at suse dot de  2006-09-12 16:30 -------
Let's think a bit more about this issue, without forgetting, however, that our
default (*) string class is *reference counted*: that means that upon s1=s2 the
string s2 is *not* actually copied, only the reference count updated. In other
terms, I'm afraid that changing the concerned behavior amounts to not doing
(whenever possible, of course) shallow copies in the assignments, which,
overall, I don't think is an option for a reference counted implementation. Can
you think of a compromise solution? In principle an heuristics should be able
to tell assign when doing a deep copy of a few chars (compared to the size of
the allocated memory) is better (long term, so to speak) than doing a shallow
copy. Note that the s1 string could be very big for many reasons, "by chance",
certainly not only because of a recent resize... Any thoughts?

(*) I'm saying default because actually starting with gcc4.1.0 we are
delivering an alternate, non-reference counted implementation in ext/vstring,
which maybe you could try, at some point.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29037

Reply via email to