I think adding a dedicated method would help clarify and encourage
performant code.  For example, I sped up the snippet below after
seeing that StringBuilder.append(<CharSequence>) has a fast path
when the arg is another StringBuilder, which isn't clear from the javadoc.


public class ScalaSB implements java.lang.CharSequence {
  final StringBuilder sb;
  ...

  public append(ScalaSB other) {
-     sb.append(other);
+    sb.append(other.sb);
  }
}

Reply via email to