You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2011/03/17 18:04:29 UTC

[jira] Resolved: (WICKET-3531) Multiple replace function call can be replaced with a single for loop to improve performance

     [ https://issues.apache.org/jira/browse/WICKET-3531?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-3531.
-----------------------------------

    Resolution: Won't Fix
      Assignee: Igor Vaynberg

we will not fix this until this shows up as a hotspot in the profiler. until then code reusability and maintainability are more important.

> Multiple replace function call can be replaced with a single for loop to improve performance 
> ---------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3531
>                 URL: https://issues.apache.org/jira/browse/WICKET-3531
>             Project: Wicket
>          Issue Type: Bug
>          Components: site
>    Affects Versions: 1.4.9
>            Reporter: Xiaoming Shi
>            Assignee: Igor Vaynberg
>         Attachments: test.java
>
>
> {noformat}
> ./apache-wicket-1.4.9/src/wicket/src/main/java/org/apache/wicket/Component.java   line: 1562
> ./apache-wicket-1.4.9/src/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/DiskPageStore.java   line: 410
> {noformat}
> 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

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira