You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Xiaoming Shi (JIRA)" <ji...@apache.org> on 2011/02/23 21:06:38 UTC
[jira] Updated: (CXF-3360) repeated replace() function calls damage
the performance
[ https://issues.apache.org/jira/browse/CXF-3360?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Xiaoming Shi updated CXF-3360:
------------------------------
Description:
In the function sanitize(String in)
./apache-cxf-2.3.2-src/common/common/src/main/java/org/apache/cxf/management/InstrumentationManager.java line: 307
6 consecutive replace() is called to remove the special characters. It's 5+ times slower than using a for loop replace them all.
{noformat}
e.g.
- str.replace('a', '#');
- str.replace('b', '%');
+ StringBuilder sb = new StringBuilder( str.length() );
+ for (int i=0; i < str.length(); i++)
+ {
+ char c = str.charAt(i);
+ if ( c == 'a' )
+ sb.append('#');
+ else if ( c== 'b' )
+ sb.append('%');
+ }
+ str = sb.toString();
{noformat}
This bug has the same problem as the MySQL bug : http://bugs.mysql.com/bug.php?id=45699
was:
In the function sanitize(String in)
./apache-cxf-2.3.2-src/common/common/src/main/java/org/apache/cxf/management/InstrumentationManager.java line: 307
6 consecutive replace() is called to remove the special characters. It's 5+ times slower than using a for loop replace them all.
e.g.
- str.replace('a', '#');
- str.replace('b', '%');
+ StringBuilder sb = new StringBuilder( str.length() );
+ for (int i=0; i < str.length(); i++)
+ {
+ char c = str.charAt(i);
+ if ( c == 'a' )
+ sb.append('#');
+ else if ( c== 'b' )
+ sb.append('%');
+ }
+ str = sb.toString();
This bug has the same problem as the MySQL bug : http://bugs.mysql.com/bug.php?id=45699
> repeated replace() function calls damage the performance
> --------------------------------------------------------
>
> Key: CXF-3360
> URL: https://issues.apache.org/jira/browse/CXF-3360
> Project: CXF
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.3.2
> Reporter: Xiaoming Shi
>
> In the function sanitize(String in)
> ./apache-cxf-2.3.2-src/common/common/src/main/java/org/apache/cxf/management/InstrumentationManager.java line: 307
> 6 consecutive replace() is called to remove the special characters. It's 5+ times slower than using a for loop replace them all.
> {noformat}
> e.g.
> - str.replace('a', '#');
> - str.replace('b', '%');
> + StringBuilder sb = new StringBuilder( str.length() );
> + for (int i=0; i < str.length(); i++)
> + {
> + char c = str.charAt(i);
> + if ( c == 'a' )
> + sb.append('#');
> + else if ( c== 'b' )
> + sb.append('%');
> + }
> + str = sb.toString();
> {noformat}
> This bug has the same problem as the MySQL bug : http://bugs.mysql.com/bug.php?id=45699
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira