Author: doogie
Date: Fri Jul 8 00:38:19 2011 New Revision: 1144106 URL: http://svn.apache.org/viewvc?rev=1144106&view=rev Log: OPTIMIZE: Don't use string addition, instead use StringBuilder. Modified: ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumEvents.java ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumServices.java Modified: ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumEvents.java?rev=1144106&r1=1144105&r2=1144106&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumEvents.java (original) +++ ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumEvents.java Fri Jul 8 00:38:19 2011 @@ -102,15 +102,17 @@ public class ScrumEvents { Debug.log(EntEx.getMessage(), module); } if (UtilValidate.isNotEmpty(noTimeEntryList)) { - String warningData = ""; + StringBuilder warningDataBuffer = new StringBuilder(); int size = noTimeEntryList.size(); for (Map<String, Object> dataMap : noTimeEntryList) { if (--size == 0) { - warningData += dataMap.get("timesheetId"); + warningDataBuffer.append(dataMap.get("timesheetId")); } else { - warningData += dataMap.get("timesheetId") + ", "; + warningDataBuffer.append(dataMap.get("timesheetId")).append(", "); } + warningDataBuffer.append(dataMap.get("timesheetId")); } + String warningData = warningDataBuffer.toString(); Debug.logInfo("The following time sheet no time entry: [" + warningData + "]", module); request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage("scrumUiLabels", "ScrumTimesheetWarningMessage", UtilMisc.toMap("warningMessage", warningData), UtilHttp.getLocale(request))); } Modified: ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumServices.java?rev=1144106&r1=1144105&r2=1144106&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumServices.java (original) +++ ofbiz/trunk/specialpurpose/scrum/src/org/ofbiz/scrum/ScrumServices.java Fri Jul 8 00:38:19 2011 @@ -113,8 +113,8 @@ public class ScrumServices { String revision = (String) context.get("revision"); String repository = (String) context.get("repository"); Map<String, Object> result = ServiceUtil.returnSuccess(); - String logMessage = ""; - String diffMessage = ""; + StringBuilder logMessage = new StringBuilder(); + StringBuilder diffMessage = new StringBuilder(); try { if (UtilValidate.isNotEmpty(repository) && UtilValidate.isNotEmpty(revision)) { String logline = null; @@ -122,20 +122,20 @@ public class ScrumServices { Process logProcess = Runtime.getRuntime().exec(logCommand); BufferedReader logIn = new BufferedReader(new InputStreamReader(logProcess.getInputStream())); while ((logline = logIn.readLine()) != null) { - logMessage += logline + "\n"; + logMessage.append(logline).append("\n"); } String diffline = null; String diffCommand = "svn diff -r" + Integer.toString((Integer.parseInt(revision.trim()) - 1)) + ":" + revision + " " + repository; Process diffProcess = Runtime.getRuntime().exec(diffCommand); BufferedReader diffIn = new BufferedReader(new InputStreamReader(diffProcess.getInputStream())); while ((diffline = diffIn.readLine()) != null) { - diffMessage += diffline + "\n"; + diffMessage.append(diffline).append("\n"); } } result.put("revision", revision); result.put("repository", repository); - result.put("logMessage", logMessage); - result.put("diffMessage", diffMessage); + result.put("logMessage", logMessage.toString()); + result.put("diffMessage", diffMessage.toString()); } catch (IOException e) { e.printStackTrace(); return ServiceUtil.returnError(e.getMessage()); |
Free forum by Nabble | Edit this page |