3 ms·
The behavior would differ, but it would be the better behaviors for the length of the String. For large strings, it would work exactly like it did before with
by bsdetector 11y ago
The behavior would differ, but it would be the better behaviors for the length of the String.
For large strings, it would work exactly like it did before with fast views. And since the existing code already knew about memory sharing this wouldn't be a new problem for any code.
For small strings, it would now be faster and have smaller memory footprint. Existing programs would be faster and better performing.
I think the main reason this is a bad idea is that String is final. The way to do this properly is with two classes, SmallString and LargeString, and then using hotspot to optimize the program for how they are used. But that is not possible without changing the API.