https://issues.apache.org/bugzilla/show_bug.cgi?id=50921
Summary: Multiple replace function call can be replaced with a single for loop to improve performance Product: Lenya Version: 2.0.3 Platform: PC Status: NEW Severity: normal Priority: P2 Component: Miscellaneous AssignedTo: dev@lenya.apache.org ReportedBy: xiaom...@cs.wisc.edu ./apache-lenya-2.0.3-src/externals/cocoon_2_1_x/src/java/org/apache/cocoon/bean/Target.java line: 371 more than 3 consecutive replace() is called to remove the special characters. It's 3+ 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('%'); + else + sb.append(c); + } + str = sb.toString(); {noformat} This bug has the same problem as the MySQL bug : http://bugs.mysql.com/bug.php?id=45699 -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lenya.apache.org For additional commands, e-mail: dev-h...@lenya.apache.org