29 ms·
Sorry, yes, we were talking about different things. Calling String.substring() used to not copy the original char array, and would instead just store an offset
by hn_throwaway_99 6y ago
Sorry, yes, we were talking about different things. Calling String.substring() used to not copy the original char array, and would instead just store an offset and length in the new String, but still point to the char array of the original String. This could cause memory leaks, and the commit you referenced fixes that.
I was referring to String interning, where literals defined in code are only created once even if they are duplicated, and the API provides String.intern() to get the "canonical" instance of a String.