Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Issue 2099683003: Optimize whitespace skipping in the CSSParser. (Closed)

Created:
4 years, 6 months ago by esprehn
Modified:
4 years, 5 months ago
CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-css, chromium-reviews, dglazkov+blink, rwlbuis
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Optimize 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. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+21 lines, -12 lines) Patch
M third_party/WebKit/Source/core/css/parser/CSSTokenizer.h View 1 chunk +0 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/css/parser/CSSTokenizer.cpp View 1 5 chunks +4 lines, -11 lines 0 comments Download
M third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h View 1 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.cpp View 2 chunks +15 lines, -0 lines 0 comments Download

Messages

Total messages: 18 (9 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2099683003/1
4 years, 6 months ago (2016-06-25 03:58:31 UTC) #3
esprehn
4 years, 6 months ago (2016-06-25 04:15:26 UTC) #5
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 6 months ago (2016-06-25 06:02:23 UTC) #7
Timothy Loh
lgtm
4 years, 5 months ago (2016-06-27 00:15:18 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2099683003/1
4 years, 5 months ago (2016-06-27 00:56:55 UTC) #10
commit-bot: I haz the power
Failed to apply patch for third_party/WebKit/Source/core/css/parser/CSSTokenizerInputStream.h: While running git apply --index -3 -p1; error: patch ...
4 years, 5 months ago (2016-06-27 02:52:15 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2099683003/20001
4 years, 5 months ago (2016-06-27 03:51:55 UTC) #15
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 5 months ago (2016-06-27 05:04:50 UTC) #16
commit-bot: I haz the power
4 years, 5 months ago (2016-06-27 05:07:29 UTC) #18
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/d04741aea9777fd9b26c98508c262f9c404584de
Cr-Commit-Position: refs/heads/master@{#402116}

Powered by Google App Engine
This is Rietveld 408576698