Changeset 160526 in webkit


Ignore:
Timestamp:
Dec 12, 2013 8:59:44 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Improve the find word boundary performance
https://bugs.webkit.org/show_bug.cgi?id=125619

In endWordBoundary case, the textBreakPrevious call in findWordBoundary is unnecessary.
So use separate function for endWordBoundary can improve the performance.

Patch by KyungTae Kim <ktf.kim@samsung.com> on 2013-12-12
Reviewed by Darin Adler.

No tests because no operation changes.

  • editing/VisibleUnits.cpp: Use findEndWordBoundary in endWordBoundary

(WebCore::endWordBoundary):

  • platform/text/TextBoundaries.cpp: Add findEndWordBoundary function

(WebCore::findEndWordBoundary):

  • platform/text/TextBoundaries.h:
  • platform/text/mac/TextBoundaries.mm: Add findEndWordBoundary function

(WebCore::findEndWordBoundary):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r160525 r160526  
     12013-12-12  KyungTae Kim  <ktf.kim@samsung.com>
     2
     3        Improve the find word boundary performance
     4        https://bugs.webkit.org/show_bug.cgi?id=125619
     5
     6        In endWordBoundary case, the textBreakPrevious call in findWordBoundary is unnecessary.
     7        So use separate function for endWordBoundary can improve the performance.
     8
     9        Reviewed by Darin Adler.
     10
     11        No tests because no operation changes.
     12
     13        * editing/VisibleUnits.cpp: Use findEndWordBoundary in endWordBoundary
     14        (WebCore::endWordBoundary):
     15        * platform/text/TextBoundaries.cpp: Add findEndWordBoundary function
     16        (WebCore::findEndWordBoundary):
     17        * platform/text/TextBoundaries.h:
     18        * platform/text/mac/TextBoundaries.mm: Add findEndWordBoundary function
     19        (WebCore::findEndWordBoundary):
     20
    1212013-12-12  Benjamin Poulain  <bpoulain@apple.com>
    222
  • trunk/Source/WebCore/editing/VisibleUnits.cpp

    r160235 r160526  
    651651    }
    652652    needMoreContext = false;
    653     int start, end;
    654     findWordBoundary(characters, length, offset, &start, &end);
     653    int end;
     654    findEndWordBoundary(characters, length, offset, &end);
    655655    return end;
    656656}
  • trunk/Source/WebCore/platform/text/TextBoundaries.cpp

    r157330 r160526  
    9898}
    9999
     100void findEndWordBoundary(const UChar* chars, int len, int position, int* end)
     101{
     102    TextBreakIterator* it = wordBreakIterator(chars, len);
     103    *end = textBreakFollowing(it, position);
     104    if (*end < 0)
     105        *end = textBreakLast(it);
     106}
     107
    100108#endif // !PLATFORM(MAC)
    101109
  • trunk/Source/WebCore/platform/text/TextBoundaries.h

    r157330 r160526  
    4646
    4747    void findWordBoundary(const UChar*, int len, int position, int* start, int* end);
     48    void findEndWordBoundary(const UChar*, int len, int position, int* end);
    4849    int findNextWordFromIndex(const UChar*, int len, int position, bool forward);
    4950
  • trunk/Source/WebCore/platform/text/mac/TextBoundaries.mm

    r157330 r160526  
    4141}
    4242
     43void findEndWordBoundary(const UChar* chars, int len, int position, int* end)
     44{
     45    NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
     46        length:len freeWhenDone:NO];
     47    NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
     48    NSRange range = [attr doubleClickAtIndex:(position >= len) ? len - 1 : position];
     49    [attr release];
     50    [string release];
     51    *end = range.location + range.length;
     52}
     53
    4354int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
    4455{   
Note: See TracChangeset for help on using the changeset viewer.