[webkit-changes] [WebKit/WebKit] 4e349c: [WebCore] Optimize Font::applyTransforms

Yusuke Suzuki noreply at github.com
Mon Mar 4 22:59:27 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4e349ca18c0f8e55b6bdcd2786755caf68787143
      https://github.com/WebKit/WebKit/commit/4e349ca18c0f8e55b6bdcd2786755caf68787143
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2024-03-04 (Mon, 04 Mar 2024)

  Changed paths:
    M Source/WTF/wtf/Vector.h
    M Source/WTF/wtf/text/StringView.h
    M Source/WebCore/editing/cocoa/DataDetection.mm
    M Source/WebCore/platform/graphics/GlyphBuffer.h
    M Source/WebCore/platform/graphics/coretext/FontCoreText.cpp
    M Source/WebCore/platform/text/cocoa/LocaleCocoa.h
    M Source/WebCore/platform/text/cocoa/LocaleCocoa.mm
    M Tools/TestWebKitAPI/Tests/WTF/Vector.cpp

  Log Message:
  -----------
  [WebCore] Optimize Font::applyTransforms
https://bugs.webkit.org/show_bug.cgi?id=270406
rdar://123961009

Reviewed by Chris Dumez.

Font::applyTransforms is very slow. While the most of time is used in CoreText, the other part is also using much time!
This patch optimizes it.

1. We add Vector::insertFill function to insert one-item-filling into Vector. GlyphBuffer is
   doing this in a very inefficient way right now: allocating filled Vector and using insertVector.
2. Add size parameter to upconvertedCharacters and use 256 for static Vector size in Font::applyTransforms,
   to avoid unnecessary allocations.
3. LocaleCocoa::canonicalLanguageIdentifierFromString should return RetainPtr<CFStringRef>. We found that
   we are super repeatedly creating CFString when locale is specified because canonicalLanguageIdentifierFromString
   returns AtomString and we convert it to CFString. And this is very slow. Because canonicalLanguageIdentifierFromString
   is only used in this place, we should just return RetainPtr<CFStringRef>. Also we optimized the caching mechanism
   in canonicalLanguageIdentifierFromString to cache the one item out of HashMap since this one-item cache can cover almost
   all cases.

* Source/WTF/wtf/Vector.h:
(WTF::Malloc>::insertFill):
* Source/WTF/wtf/text/StringView.h:
(WTF::StringView::upconvertedCharacters const):
(WTF::StringView::UpconvertedCharacters<N>::UpconvertedCharacters):
(WTF::StringView::UpconvertedCharacters::UpconvertedCharacters): Deleted.
* Source/WebCore/editing/TextIterator.cpp:
* Source/WebCore/platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBuffer::makeHole):
* Source/WebCore/platform/graphics/coretext/FontCoreText.cpp:
(WebCore::Font::applyTransforms const):
* Source/WebCore/platform/text/cocoa/LocaleCocoa.h:
* Source/WebCore/platform/text/cocoa/LocaleCocoa.mm:
(WebCore::localeCache):
(WebCore::LocaleCocoa::canonicalLanguageIdentifierFromString):
(WebCore::LocaleCocoa::releaseMemory):
(WebCore::canonicalLocaleMap): Deleted.

Canonical link: https://commits.webkit.org/275676@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list