You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sa...@apache.org on 2011/09/14 12:38:51 UTC
svn commit: r1170521 -
/ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java
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.
Re: svn commit: r1170521 - /ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java
Posted by Sascha Rodekamp <sa...@googlemail.com>.
Ok done :-)
Regards
Sascha
Am 14.09.2011 um 13:12 schrieb Scott Gray <sc...@hotwaxmedia.com>:
> That is the policy.
>
> Regards
> Scott
>
> On 14/09/2011, at 10:58 PM, Sascha Rodekamp wrote:
>
>> Hm your right should it Be reverted?
>>
>> Am 14.09.2011 um 12:49 schrieb Adrian Crum <ad...@sandglass-software.com>:
>>
>>> This isn't a bug fix - it is an enhancement.
>>>
>>> -Adrian
>>>
>>> On 9/14/2011 11:38 AM, sascharodekamp@apache.org 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.
>>>>
>>>>
>
Re: svn commit: r1170521 - /ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java
Posted by Scott Gray <sc...@hotwaxmedia.com>.
That is the policy.
Regards
Scott
On 14/09/2011, at 10:58 PM, Sascha Rodekamp wrote:
> Hm your right should it Be reverted?
>
> Am 14.09.2011 um 12:49 schrieb Adrian Crum <ad...@sandglass-software.com>:
>
>> This isn't a bug fix - it is an enhancement.
>>
>> -Adrian
>>
>> On 9/14/2011 11:38 AM, sascharodekamp@apache.org 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.
>>>
>>>
Re: svn commit: r1170521 - /ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java
Posted by Sascha Rodekamp <sa...@googlemail.com>.
Hm your right should it Be reverted?
Am 14.09.2011 um 12:49 schrieb Adrian Crum <ad...@sandglass-software.com>:
> This isn't a bug fix - it is an enhancement.
>
> -Adrian
>
> On 9/14/2011 11:38 AM, sascharodekamp@apache.org 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.
>>
>>
Re: svn commit: r1170521 - /ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilValidate.java
Posted by Adrian Crum <ad...@sandglass-software.com>.
This isn't a bug fix - it is an enhancement.
-Adrian
On 9/14/2011 11:38 AM, sascharodekamp@apache.org 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.
>
>