You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2007/10/17 19:47:12 UTC

svn commit: r585600 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java

Author: doogie
Date: Wed Oct 17 10:47:11 2007
New Revision: 585600

URL: http://svn.apache.org/viewvc?rev=585600&view=rev
Log:
Use StringBuilder instead of string addition.  Closes
https://issues.apache.org/jira/browse/OFBIZ-1339

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java?rev=585600&r1=585599&r2=585600&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java Wed Oct 17 10:47:11 2007
@@ -126,17 +126,17 @@
     }
 
     protected String indexString(int[] index) {
-        String str = "";
+        StringBuilder str = new StringBuilder();
         if (index != null) {
             for (int i = 0; i < index.length; i++) {
-                if (!"".equals(str)) {
-                    str = str + ", ";
+                if (str.length() != 0) {
+                    str.append(", ");
                 }
-                str = str + index[i];
+                str.append(index[i]);
             }
         }
 
-        return str;
+        return str.toString();
     }
 
     protected int[] getFieldIndex(int field) {
@@ -252,15 +252,15 @@
     }
 
     public static void main(String[] args) throws Exception {
-        String name = "";
+        StringBuilder name = new StringBuilder();
         for (int i = 0; i < args.length; i++) {
-            if (!"".equals(name)) {
-                name = name + " ";
+            if (name.length() != 0) {
+                name.append(" ");
             }
-            name = name + args[i];
+            name.append(args[i]);
         }
 
-        Map nameMap = parseName(name, true);
+        Map nameMap = parseName(name.toString(), true);
         Iterator i = nameMap.keySet().iterator();
         while (i.hasNext()) {
             String f = (String) i.next();