[webkit-changes] cvs commit: WebCore/khtml/editing visible_text.cpp

Justin justing at opensource.apple.com
Thu Nov 3 21:58:12 PST 2005


justing     05/11/03 21:58:11

  Modified:    .        ChangeLog
               khtml/editing visible_text.cpp
  Log:
          Bugzilla 5604: plainText (visible_text.cpp) performance improvement
  
          Reviewed by justin and darin
  
          Optimized plainText for a ~100% speedup in most cases.
  
          No test cases added, change only effects performance.
  
          * khtml/editing/visible_text.cpp:
          (khtml::TextIterator::rangeLength): Removed an extraneous comment.
          (khtml::plainText): The length of the string to be created was
          pre-calculated to avoid the expense of many QString::append() calls.
          Removed this since TextIterator::advance() is much more expensive
          than append.
  
  Revision  Changes    Path
  1.335     +17 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.334
  retrieving revision 1.335
  diff -u -r1.334 -r1.335
  --- ChangeLog	4 Nov 2005 01:38:18 -0000	1.334
  +++ ChangeLog	4 Nov 2005 05:58:08 -0000	1.335
  @@ -1,3 +1,20 @@
  +2005-11-03  Evan Gross  <evan at rainmakerinc.com>
  +
  +        Bugzilla 5604: plainText (visible_text.cpp) performance improvement
  +        
  +        Reviewed by justin and darin
  +        
  +        Optimized plainText for a ~100% speedup in most cases.
  +        
  +        No test cases added, change only effects performance.
  +
  +        * khtml/editing/visible_text.cpp:
  +        (khtml::TextIterator::rangeLength): Removed an extraneous comment.
  +        (khtml::plainText): The length of the string to be created was 
  +        pre-calculated to avoid the expense of many QString::append() calls.
  +        Removed this since TextIterator::advance() is much more expensive 
  +        than append.
  +
   2005-11-03  Timothy Hatcher  <timothy at apple.com>
   
           Reviewed by Darin and Vicki.
  
  
  
  1.40      +0 -7      WebCore/khtml/editing/visible_text.cpp
  
  Index: visible_text.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/visible_text.cpp,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- visible_text.cpp	2 Nov 2005 08:52:43 -0000	1.39
  +++ visible_text.cpp	4 Nov 2005 05:58:11 -0000	1.40
  @@ -973,7 +973,6 @@
   
   int TextIterator::rangeLength(const RangeImpl *r)
   {
  -    // Allocate string at the right size, rather than building it up by successive append calls.
       int length = 0;
       for (TextIterator it(r); !it.atEnd(); it.advance()) {
           length += it.length();
  @@ -1029,13 +1028,7 @@
   
   QString plainText(const RangeImpl *r)
   {
  -    // Allocate string at the right size, rather than building it up by successive append calls.
  -    int length = 0;
  -    for (TextIterator it(r); !it.atEnd(); it.advance()) {
  -        length += it.length();
  -    }
       QString result("");
  -    result.reserve(length);
       for (TextIterator it(r); !it.atEnd(); it.advance()) {
           result.append(it.characters(), it.length());
       }
  
  
  



More information about the webkit-changes mailing list