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

Reply via email to