.NET on a string

Christopher Wright dhasenan at gmail.com
Mon Mar 23 15:46:45 PDT 2009


Steven Schveighoffer wrote:
> I thought one of the benefits of having immutable strings is that 
> substrings were just pointers to slices of the original data in Java and 
> .NET.  So every time I do a substring in Java and .NET, it creates a 
> copy of the data?  That seems very wasteful, especially when the data is 
> immutable...

I checked the source code for ClassPath's string implementation about a 
year ago. It copies to create a substring. I thought it was stupid.

On the other hand, ClassPath is an open source project and doesn't have 
hundreds of millions of dollars in backing, so I imagine Sun's String 
implementation is slightly smarter.



More information about the Digitalmars-d mailing list