svn commit: r13642 - trunk/src_new/org/argouml: cognitive cognitive/checklist kernel notation/providers/java util

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: penyaskito
Date: 2007-10-07 04:02:43-0700
New Revision: 13642

Modified:
   trunk/src_new/org/argouml/cognitive/ListSet.java
   trunk/src_new/org/argouml/cognitive/checklist/Checklist.java
   trunk/src_new/org/argouml/kernel/ProjectImpl.java
   trunk/src_new/org/argouml/notation/providers/java/NotationUtilityJava.java
   trunk/src_new/org/argouml/util/MyTokenizer.java

Log:
Removed string concatenation in loops, using instead StringBuilder.

Modified: trunk/src_new/org/argouml/cognitive/ListSet.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/cognitive/ListSet.java?view=diff&rev=13642&p1=trunk/src_new/org/argouml/cognitive/ListSet.java&p2=trunk/src_new/org/argouml/cognitive/ListSet.java&r1=13641&r2=13642
==============================================================================
--- trunk/src_new/org/argouml/cognitive/ListSet.java	(original)
+++ trunk/src_new/org/argouml/cognitive/ListSet.java	2007-10-07 04:02:43-0700
@@ -318,14 +318,15 @@
      * @see java.lang.Object#toString()
      */
     public String toString() {
-        String res = "Set{";
+        StringBuilder sb = new StringBuilder("Set{");        
         for (Iterator it = iterator(); it.hasNext(); ) {
-            res += it.next();
+            sb.append(it.next());
             if (it.hasNext()) {
-                res += ", ";
+                sb.append(", ");
             }
         }
-        return res + "}";
+        sb.append("}");
+        return sb.toString();
     }
 
     /**

Modified: trunk/src_new/org/argouml/cognitive/checklist/Checklist.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/cognitive/checklist/Checklist.java?view=diff&rev=13642&p1=trunk/src_new/org/argouml/cognitive/checklist/Checklist.java&p2=trunk/src_new/org/argouml/cognitive/checklist/Checklist.java&r1=13641&r2=13642
==============================================================================
--- trunk/src_new/org/argouml/cognitive/checklist/Checklist.java	(original)
+++ trunk/src_new/org/argouml/cognitive/checklist/Checklist.java	2007-10-07 04:02:43-0700
@@ -140,13 +140,13 @@
      */
     @Override
     public String toString() {
-	String res;
-	res = getClass().getName() + " {\n";
+	StringBuilder sb = new StringBuilder();
+	sb.append(getClass().getName() + " {\n");
         for (CheckItem item : this) {
-	    res += "    " + item.toString() + "\n";
+	    sb.append("    " + item.toString() + "\n");
 	}
-	res += "  }";
-	return res;
+	sb.append("  }");
+	return sb.toString();
     }
 
 }

Modified: trunk/src_new/org/argouml/kernel/ProjectImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProjectImpl.java?view=diff&rev=13642&p1=trunk/src_new/org/argouml/kernel/ProjectImpl.java&p2=trunk/src_new/org/argouml/kernel/ProjectImpl.java&r1=13641&r2=13642
==============================================================================
--- trunk/src_new/org/argouml/kernel/ProjectImpl.java	(original)
+++ trunk/src_new/org/argouml/kernel/ProjectImpl.java	2007-10-07 04:02:43-0700
@@ -1153,13 +1153,13 @@
 
 
     public String repair() {
-        String report = "";
+        StringBuilder report = new StringBuilder();
         Iterator it = members.iterator();
         while (it.hasNext()) {
             ProjectMember member = (ProjectMember) it.next();
-            report += member.repair();
+            report.append(member.repair());
         }
-        return report;
+        return report.toString();
     }
 
 

Modified: trunk/src_new/org/argouml/notation/providers/java/NotationUtilityJava.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/notation/providers/java/NotationUtilityJava.java?view=diff&rev=13642&p1=trunk/src_new/org/argouml/notation/providers/java/NotationUtilityJava.java&p2=trunk/src_new/org/argouml/notation/providers/java/NotationUtilityJava.java&r1=13641&r2=13642
==============================================================================
--- trunk/src_new/org/argouml/notation/providers/java/NotationUtilityJava.java	(original)
+++ trunk/src_new/org/argouml/notation/providers/java/NotationUtilityJava.java	2007-10-07 04:02:43-0700
@@ -192,7 +192,7 @@
      */
     static String generatePath(Object modelElement, 
             HashMap args) {
-        String s = "";
+        StringBuilder s = new StringBuilder();
         if (NotationProvider.isValue("pathVisible", args)) {
             Stack stack = new Stack();
             Object ns = Model.getFacade().getNamespace(modelElement);
@@ -201,14 +201,14 @@
                 ns = Model.getFacade().getNamespace(ns);
             }
             while (!stack.isEmpty()) {
-                s += (String) stack.pop() + ".";
+                s.append((String) stack.pop() + ".");
             }
 
-            if (s.length() > 0 && !s.endsWith(".")) {
-                s += ".";
+            if (s.length() > 0 && !(s.lastIndexOf(".") == s.length() - 1)) {
+                s.append(".");
             }
         }
-        return s;
+        return s.toString();
     }
 
     /**

Modified: trunk/src_new/org/argouml/util/MyTokenizer.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/util/MyTokenizer.java?view=diff&rev=13642&p1=trunk/src_new/org/argouml/util/MyTokenizer.java&p2=trunk/src_new/org/argouml/util/MyTokenizer.java&r1=13641&r2=13642
==============================================================================
--- trunk/src_new/org/argouml/util/MyTokenizer.java	(original)
+++ trunk/src_new/org/argouml/util/MyTokenizer.java	2007-10-07 04:02:43-0700
@@ -724,7 +724,7 @@
 	TokenSep first = null;
 	TokenSep p = null;
 	int idx0, idx1, length;
-	String val = "";
+	StringBuilder val = new StringBuilder();
 	char c;
 
 	length = str.length();
@@ -734,17 +734,17 @@
 		if (c == '\\') {
 		    idx1++;
 		    if (idx1 < length)
-			val += str.charAt(idx1);
+			val.append(str.charAt(idx1));
 		} else if (c == ',') {
 		    break;
 		} else {
-		    val += c;
+		    val.append(c);
 		}
 	    }
 	    idx1 = Math.min(idx1, length);
 	    if (idx1 > idx0) {
-		p = new TokenSep(val);
-		val = "";
+		p = new TokenSep(val.toString());
+		val = new StringBuilder();
 		p.setNext(first);
 		first = p;
 	    }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.