Hm your right should it Be reverted? Am 14.09.2011 um 12:49 schrieb Adrian Crum <[email protected]>:
> This isn't a bug fix - it is an enhancement. > > -Adrian > > On 9/14/2011 11:38 AM, [email protected] wrote: >> Author: sascharodekamp >> Date: Wed Sep 14 10:38:50 2011 >> New Revision: 1170521 >> >> URL: http://svn.apache.org/viewvc?rev=1170521&view=rev >> Log: >> Building a String using concatenation in a loop >> (https://issues.apache.org/jira/browse/OFBIZ-4416). A patch from Dimitri >> Unruh: In UtilValidate.java some methods building a String using >> concatenation in a loop. We can obtaine better performance by using a >> StringBuilder >> >> Modified: >> >> ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java >> >> Modified: >> ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java?rev=1170521&r1=1170520&r2=1170521&view=diff >> ============================================================================== >> --- >> ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java >> (original) >> +++ >> ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java >> Wed Sep 14 10:38:50 2011 >> @@ -264,31 +264,31 @@ public class UtilValidate { >> /** Removes all characters which appear in string bag from string s. */ >> public static String stripCharsInBag(String s, String bag) { >> int i; >> - String returnString = ""; >> + StringBuilder stringBuilder = new StringBuilder(""); >> >> // Search through string's characters one by one. >> // If character is not in bag, append to returnString. >> for (i = 0; i< s.length(); i++) { >> char c = s.charAt(i); >> >> - if (bag.indexOf(c) == -1) returnString += c; >> + if (bag.indexOf(c) == -1) stringBuilder.append(c); >> } >> - return returnString; >> + return stringBuilder.toString(); >> } >> >> /** Removes all characters which do NOT appear in string bag from >> string s. */ >> public static String stripCharsNotInBag(String s, String bag) { >> int i; >> - String returnString = ""; >> + StringBuilder stringBuilder = new StringBuilder(""); >> >> // Search through string's characters one by one. >> // If character is in bag, append to returnString. >> for (i = 0; i< s.length(); i++) { >> char c = s.charAt(i); >> >> - if (bag.indexOf(c) != -1) returnString += c; >> + if (bag.indexOf(c) != -1) stringBuilder.append(c); >> } >> - return returnString; >> + return stringBuilder.toString(); >> } >> >> /** Removes all whitespace characters from s. >> >>
