String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Tue Jun 26 19:49:44 UTC 2012
Le 26/06/12 20:10, Mike Duigou a écrit :
>> StringBuilder.append(string.substring(lower, upper));
>> by:
>> StringBuilder.append(string, lower, upper);
> This would seem to be a good refactoring regardless of the substring implementation as it avoids creation of a temporary object.
The rational was that the performance advantage of using
System.arraycopy(...) instead than a loop over CharSequence.charAt(int)
may compensate the cost of creating a temporary object. I would not be
surprised if the former was faster than the later for large substrings
despite the temporary object creation. However it may not be true
anymore now that substring(...) performs a copy. Of course this would
need to be verified with benchmark...
Martin
More information about the core-libs-dev
mailing list