In JDK 1.3, StringBuffer makes the String concatenations faster.
public String concat(String s1, String s2) {
StringBuffer sb = new StringBuffer();
sb.append(s1);
sb.append(s2);
return sb.toString();
}
JDK 1.5 comes with StringBuilder (which is faster than StringBuffer) and the method:
public String concat(String s1, String s2) {
return s1 + s2;
}
is translated to:
public String concat(String s1, String s2) {
return new StringBuilder().append(s1).append(s2).toString();
}
Change-Id: I2924fcdf23d7ffbb567d9e924d02edcab4d21be6
NOTE: StringBuffer is synchronized, StringBuilder is not.
Reviewed-on: https://gerrit.libreoffice.org/11436
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>