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 2009/04/26 07:19:46 UTC

svn commit: r768652 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java

Author: doogie
Date: Sun Apr 26 05:19:45 2009
New Revision: 768652

URL: http://svn.apache.org/viewvc?rev=768652&view=rev
Log:
Don't do string addition, especially in a timing function.

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

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java?rev=768652&r1=768651&r2=768652&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java Sun Apr 26 05:19:45 2009
@@ -95,20 +95,20 @@
         // time this call to avoid it interfering with the main timer
         long tsStart = System.currentTimeMillis();
 
-        String retString = "[[" + message + "- total:" + secondsSinceStart();
+        StringBuilder retBuf = new StringBuilder();
+        retBuf.append("[[").append(message).append("- total:").append(secondsSinceStart());
         if (lastMessage != null) {
-            retString += ",since last(" + ((lastMessage.length() > 20) ? (lastMessage.substring(0, 17) + "...") : lastMessage) + "):" +
-                    secondsSinceLast() + "]]";
-        } else {
-            retString += "]]";
+            retBuf.append(",since last(").append(((lastMessage.length() > 20) ? (lastMessage.substring(0, 17) + "...") : lastMessage)).append("):").append(secondsSinceLast());
         }
+        retBuf.append("]]");
 
         // append the timer name
         if (UtilValidate.isNotEmpty(timerName)) {
-            retString = retString + " - '" + timerName + "'";
+            retBuf.append(" - '").append(timerName).append("'");
         }
 
         lastMessage = message;
+        String retString = retBuf.toString();
         if (log) Debug.log(Debug.TIMING, null, retString, module, "org.ofbiz.base.util.UtilTimer");
 
         // have lastMessageTime come as late as possible to just time what happens between calls