
9 Aug
2007
9 Aug
'07
9:09 p.m.
Hervé Brönnimann wrote:
A shared string would be *extremely* useful. Most of the projects I'm working on these days spend a non-negligible time copying strings... FWIW, HB
A special data structure was designed for that, it's called a rope. It allows various substrings to be shared by different strings. However, it is not much used because: - A lot of existing code wants efficient ways to have contiguous strings, - A lot of people consider sharing to be evil (and sometimes rightly so. I don't see the point of sharing only at the whole string level. Libraries that produce needless copies are simply ill-designed, and thus it is true great parts of the standard library are), - Sharing, if used, works way better with immutable objects.