Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3360

repeated replace() function calls damage the performance

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.2
    • 2.4, 2.3.4
    • Core
    • None

    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.

      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();
      

      This bug has the same problem as the MySQL bug : http://bugs.mysql.com/bug.php?id=45699

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            nancyesmis Xiaoming Shi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: