Chromium Code Reviews
DescriptionOptimize whitespace skipping in the CSSParser.
The code was using nextInputChar() which would make a function call,
check the length, call StringImpl operator[] which would check is8Bit()
then branch looking for a NUL to do replacement, then always call the
UChar version of isHTMLSpace, then call consume() which would again call
nextInputChar() doing a check on length, String operator[], another
branch only to discard the return value entirely, and finally call
advance() to move the offset forward.
We can do much better than this by introducing
CSSTokenizerInputStream::advanceUntilNonWhitespace which doesn't do
replacement (since it doesn't matter for whitespace), doesn't do
repeated length checks, and specializes on the character type so we
can use isHTMLSpace<LChar> when possible.
This yields a 15% performance improvement when parsing long runs of
whitespace like you might find in a stylesheet when tested using
inline style with this simple benchmark:
// 32 spaces before the value.
for (var i = 0; i < 99999; ++i)
span.style.color = " red";
This will benefit any site that has a bunch of whitespace in the
stylesheets. Many web components applications (ex. Polymer Shop)
have lots of it.
BUG=605792
Committed: https://crrev.com/d04741aea9777fd9b26c98508c262f9c404584de
Cr-Commit-Position: refs/heads/master@{#402116}
Patch Set 1 #Patch Set 2 : rebase. #
Messages
Total messages: 18 (9 generated)
|
||||||||||||||||||||||||||||||||||||||||||||||