From 23516c108a67d9d37fb4d1d540e8d97c4e7a312b Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 8 Jun 2014 16:37:30 +0200 Subject: [PATCH] Improve toString performance. --- src/fr/devinsy/util/StringList.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/fr/devinsy/util/StringList.java b/src/fr/devinsy/util/StringList.java index 6d01c4a..2ab23f5 100755 --- a/src/fr/devinsy/util/StringList.java +++ b/src/fr/devinsy/util/StringList.java @@ -709,14 +709,24 @@ public class StringList extends ArrayList implements CharSequence { String result; - StringBuffer buffer = new StringBuffer(length()); - - for (String string : this) + if (size() == 1) { - buffer.append(string); - } + // + result = get(0); - result = buffer.toString(); + } + else + { + // + StringBuffer buffer = new StringBuffer(length()); + + for (String string : this) + { + buffer.append(string); + } + + result = buffer.toString(); + } // return (result);