String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String (original) (raw)
Martin Desruisseaux martin.desruisseaux at geomatys.fr
Tue Jun 26 19:49:44 UTC 2012
- Previous message: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String
- Next message: hg: jdk8/tl/jdk: 6924259: Remove offset and count fields from java.lang.String
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: String.subSequence and CR#6924259: Remove offset and count fields from java.lang.String
- Next message: hg: jdk8/tl/jdk: 6924259: Remove offset and count fields from java.lang.String
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]