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

Issue 1430603003: Add a consumeIdent<CSSValueID...> helper (Closed)

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

Description

Add a consumeIdent<CSSValueID...> helper This patch adds an additional consumeIdent helper function to the new CSSPropertyParser, which takes a list of CSSValueIDs as a template argument to accept. BUG=499780 Committed: https://crrev.com/770eaea66cc4cfbb14ced3dc8dc5434716ed540a Cr-Commit-Position: refs/heads/master@{#357026}

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+26 lines, -59 lines) Patch
M third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp View 9 chunks +26 lines, -59 lines 2 comments Download

Depends on Patchset:

Messages

Total messages: 20 (4 generated)
Timothy Loh
So there are more similar helpers that we could potentially add, but they might not ...
5 years, 1 month ago (2015-10-29 04:59:41 UTC) #2
Timothy Loh
On 2015/10/29 04:59:41, Timothy Loh wrote: > So there are more similar helpers that we ...
5 years, 1 month ago (2015-10-29 05:35:24 UTC) #3
Timothy Loh
On 2015/10/29 05:35:24, Timothy Loh wrote: > On 2015/10/29 04:59:41, Timothy Loh wrote: > > ...
5 years, 1 month ago (2015-10-29 05:35:30 UTC) #4
Timothy Loh
On 2015/10/29 05:35:30, Timothy Loh wrote: > On 2015/10/29 05:35:24, Timothy Loh wrote: > > ...
5 years, 1 month ago (2015-10-29 05:35:41 UTC) #5
Timothy Loh
oops, ignore the replies, rietveld was being silly... Anyway, I just realised that consumeEither and ...
5 years, 1 month ago (2015-10-29 05:36:48 UTC) #6
Timothy Loh
To make consumeEither and consumeList work without being too horrible, they'd have to use currying, ...
5 years, 1 month ago (2015-10-29 05:40:59 UTC) #7
rwlbuis
lgtm This looks great! https://codereview.chromium.org/1430603003/diff/1/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp File third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp (right): https://codereview.chromium.org/1430603003/diff/1/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp#newcode1723 third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp:1723: ASSERT_NOT_REACHED(); You could even remove ...
5 years, 1 month ago (2015-10-29 20:23:37 UTC) #8
Timothy Loh
https://codereview.chromium.org/1430603003/diff/1/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp File third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp (right): https://codereview.chromium.org/1430603003/diff/1/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp#newcode1723 third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp:1723: ASSERT_NOT_REACHED(); On 2015/10/29 20:23:37, rwlbuis wrote: > You could ...
5 years, 1 month ago (2015-10-30 00:00:36 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1430603003/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1430603003/1
5 years, 1 month ago (2015-10-30 00:02:37 UTC) #11
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/114148)
5 years, 1 month ago (2015-10-30 00:08:52 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1430603003/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1430603003/1
5 years, 1 month ago (2015-10-30 02:16:51 UTC) #15
commit-bot: I haz the power
Committed patchset #1 (id:1)
5 years, 1 month ago (2015-10-30 02:21:36 UTC) #16
commit-bot: I haz the power
Patchset 1 (id:??) landed as https://crrev.com/770eaea66cc4cfbb14ced3dc8dc5434716ed540a Cr-Commit-Position: refs/heads/master@{#357026}
5 years, 1 month ago (2015-10-30 02:22:32 UTC) #17
esprehn
Does the compiler turn this into a jump table? The switch statements are generally better ...
5 years, 1 month ago (2015-10-30 03:23:19 UTC) #18
esprehn
On 2015/10/30 at 03:23:19, esprehn wrote: > Does the compiler turn this into a jump ...
5 years, 1 month ago (2015-10-30 03:25:34 UTC) #19
Timothy Loh
5 years, 1 month ago (2015-10-30 03:38:54 UTC) #20
Message was sent while issue was closed.
On 2015/10/30 03:25:34, esprehn wrote:
> On 2015/10/30 at 03:23:19, esprehn wrote:
> > Does the compiler turn this into a jump table? The switch statements are
> generally better than this big set of || cases with recursion unless the
> compiler is smart enough to transform those templates.
> 
> You also made GenericFontFamily (which is very common) go from two branches:
> 
> if (range.peek().id() >= CSSValueSerif && range.peek().id() <=
> CSSValueWebkitBody
> 
> to 6 branches.
> 
> consumeIdent<CSSValueSerif, CSSValueSansSerif, CSSValueCursive,
CSSValueFantasy,
> CSSValueMonospace, CSSValueWebkitBody>
> 
> maybe that doesn't impact real content enough though.

I made a mini test case (of course, I can't say from this whether the actual
Chrome build will be optimised similarly). https://gcc.godbolt.org/ says:
-O2 makes this range checks on clang and gcc
-O1 on gcc has everything inlined but doesn't make range checks
-O1 on clang doesn't inline

enum CSSValueID {
    A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
};

template<typename... emptyBaseCase> inline bool identMatches(CSSValueID id) {
return false ; } 
template<CSSValueID head, CSSValueID... tail> inline bool
identMatches(CSSValueID id) 
{
    return id == head || identMatches<tail...>(id);
}

bool test(CSSValueID id) {
    return identMatches<D, E, F, G, H, I>(id);
}

Powered by Google App Engine
This is Rietveld 408576698