Ignore:
Timestamp:
Sep 9, 2021, 4:39:40 PM (4 years ago)
Author:
Darin Adler
Message:

Improve performance by using StringView, not "const StringView&"
https://bugs.webkit.org/show_bug.cgi?id=229834

Reviewed by Anders Carlsson.

Source/JavaScriptCore:

  • parser/Lexer.h:
  • runtime/IntlDateTimeFormat.cpp:

(JSC::IntlDateTimeFormat::setFormatsFromPattern):

  • runtime/IntlDateTimeFormat.h:

Use StringView, not const StringView&.

Source/WebCore:

  • html/BaseDateAndTimeInputType.h:
  • html/DateInputType.cpp:

(WebCore::DateInputType::parseToDateComponents const):

  • html/DateInputType.h:
  • html/DateTimeLocalInputType.cpp:

(WebCore::DateTimeLocalInputType::parseToDateComponents const):

  • html/DateTimeLocalInputType.h:
  • html/MonthInputType.cpp:

(WebCore::MonthInputType::parseToDateComponents const):

  • html/MonthInputType.h:
  • html/TimeInputType.cpp:

(WebCore::TimeInputType::parseToDateComponents const):

  • html/TimeInputType.h:
  • html/WeekInputType.cpp:

(WebCore::WeekInputType::parseToDateComponents const):

  • html/WeekInputType.h:
  • html/parser/HTMLParserIdioms.cpp:

(WebCore::parseMetaHTTPEquivRefresh):

  • html/parser/HTMLParserIdioms.h:
  • html/parser/HTMLSrcsetParser.h:
  • layout/formattingContexts/inline/InlineTextItem.cpp:

(WebCore::Layout::moveToNextNonWhitespacePosition):

  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::canUseSimplifiedTextMeasuring):

  • mathml/MathMLPresentationElement.cpp:

(WebCore::MathMLPresentationElement::parseNumberAndUnit):
(WebCore::MathMLPresentationElement::parseNamedSpace):

  • mathml/MathMLPresentationElement.h:
  • page/Quirks.cpp:

(WebCore::shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasForHost):

  • platform/graphics/FontCascade.cpp:

(WebCore::FontCascade::expansionOpportunityCount):
(WebCore::FontCascade::leftExpansionOpportunity):
(WebCore::FontCascade::rightExpansionOpportunity):

  • platform/graphics/FontCascade.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::conformFragmentIdentifierForURL):

  • rendering/LegacyLineLayout.cpp:

(WebCore::LegacyLineLayout::computeInlineDirectionPositionsForSegment):

  • svg/SVGParserUtilities.cpp:

(WebCore::parseNumber):
(WebCore::parseNumberOptionalNumber):
(WebCore::parsePoint):
(WebCore::parseRect):
(WebCore::parseGlyphName):
(WebCore::parseKerningUnicodeString):

  • svg/SVGParserUtilities.h:

Use StringView, not const StringView&.

Source/WTF:

Since StringView is a small structure that fits into two registers, it's not
good to pass a pointer to it; better performance to pass it by value. Note
that this is for release builds, not debug builds where StringView has
significant additional overhead when copying.

  • wtf/PrintStream.cpp:

(WTF::printInternal):

  • wtf/PrintStream.h:
  • wtf/text/StringConcatenate.h:
  • wtf/text/StringView.cpp:

(WTF::StringView::containsIgnoringASCIICase const):
(WTF::StringView::findIgnoringASCIICase const):
(WTF::StringView::startsWith const):
(WTF::StringView::startsWithIgnoringASCIICase const):
(WTF::StringView::endsWith const):
(WTF::StringView::endsWithIgnoringASCIICase const):
(WTF::StringView::GraphemeClusters::Iterator::Impl::Impl):
(WTF::StringView::GraphemeClusters::Iterator::Iterator):

  • wtf/text/StringView.h:
  • wtf/text/WTFString.h:

Use StringView, not const StringView&.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Lexer.h

    r278253 r282242  
    151151    ALWAYS_INLINE const T* currentSourcePtr() const;
    152152
    153     ALWAYS_INLINE void setCodeStart(const StringView&);
     153    ALWAYS_INLINE void setCodeStart(StringView);
    154154
    155155    ALWAYS_INLINE const Identifier* makeIdentifier(const LChar* characters, size_t length);
     
    305305
    306306template <>
    307 ALWAYS_INLINE void Lexer<LChar>::setCodeStart(const StringView& sourceString)
     307ALWAYS_INLINE void Lexer<LChar>::setCodeStart(StringView sourceString)
    308308{
    309309    ASSERT(sourceString.is8Bit());
     
    312312
    313313template <>
    314 ALWAYS_INLINE void Lexer<UChar>::setCodeStart(const StringView& sourceString)
     314ALWAYS_INLINE void Lexer<UChar>::setCodeStart(StringView sourceString)
    315315{
    316316    ASSERT(!sourceString.is8Bit());
Note: See TracChangeset for help on using the changeset viewer.