[webkit-changes] [WebKit/WebKit] 641608: Optimize the CSSVariableData constructor
Chris Dumez
noreply at github.com
Thu Sep 7 14:50:32 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 641608e9630336fbbd011dc072655ee83bdf7b03
https://github.com/WebKit/WebKit/commit/641608e9630336fbbd011dc072655ee83bdf7b03
Author: Chris Dumez <cdumez at apple.com>
Date: 2023-09-07 (Thu, 07 Sep 2023)
Changed paths:
M Source/WebCore/css/CSSVariableData.cpp
M Source/WebCore/css/CSSVariableData.h
M Source/WebCore/css/parser/CSSParserToken.h
Log Message:
-----------
Optimize the CSSVariableData constructor
https://bugs.webkit.org/show_bug.cgi?id=261285
Reviewed by Ryosuke Niwa.
Optimize the CSSVariableData constructor by:
1. Using Vector's reserveInitialCapacity() / uncheckedAppend() for m_tokens
since we know how many tokens are present in the range.
2. Populate the m_tokens vector as we traverse the token range to append to
the StringBuilder, instead of doing it later on.
3. Stop relying on CSSParserToken::copyWithUpdatedString() instead instead
update characters in place in the pre-populated vector using the new
CSSParserToken::updateCharacters(). CSSParserToken::updateCharacters()
also takes the characters as LChar/UChar instead of StringView to avoid
a redundant `is8Bit()` check.
* Source/WebCore/css/CSSVariableData.cpp:
(WebCore::CSSVariableData::updateBackingStringsInTokens):
(WebCore::CSSVariableData::CSSVariableData):
(WebCore::CSSVariableData::updateTokens): Deleted.
* Source/WebCore/css/CSSVariableData.h:
* Source/WebCore/css/parser/CSSParserToken.h:
(WebCore::CSSParserToken::updateCharacters):
Canonical link: https://commits.webkit.org/267753@main
More information about the webkit-changes
mailing list