scripting: replace StringBuffer with StringBuilder method

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>
This commit is contained in:
rbuj
2014-09-14 00:28:07 +02:00
committed by Noel Grandin
parent 40f1849e0f
commit 44304a8147
8 changed files with 9 additions and 12 deletions

View File

@@ -279,7 +279,7 @@ public class ScriptMetaData extends ScriptEntry {
if ( sourceUrl != null )
{
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
InputStream in = sourceUrl.openStream();
byte[] contents = new byte[1024];