Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.6
-
None
Description
The DGM/PDGM methods
- StringBuffer leftShift(String, Object)
- StringBuffer leftShift(StringBuffer, Object)
- StringBuilder leftShift(StringBuilder, Object)
are (up to at minimum ten times) slower than they should be. Possible faster implementations are
public static StringBuffer leftShift(String self, Object value) { final CharSequence chseq; if (value instanceof CharSequence) chseq = (CharSequence)value; else chseq = String.valueOf(value); final int capacity = 2 * (self.length() + chseq.length()); return new StringBuffer(capacity).append(self).append(chseq); } public static StringBuffer leftShift(StringBuffer self, Object value) { if (value instanceof CharSequence) return self.append((CharSequence)value); else return self.append(value); } public static StringBuilder leftShift(StringBuilder self, Object value) { if (value instanceof CharSequence) return self.append((CharSequence)value); else return self.append(value); }