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

Issue 142513003: Use Traits in SelectorQuery to avoid a lot of code duplication (Closed)

Created:
6 years, 11 months ago by Inactive
Modified:
6 years, 11 months ago
Reviewers:
esprehn, adamk, eseidel
CC:
blink-reviews, dglazkov+blink, sof, eae+blinkwatch, adamk+blink_chromium.org, tasak (please_use_google.com), abarth-chromium, rune, adamk
Visibility:
Public.

Description

Use Traits in SelectorQuery to avoid a lot of code duplication This CL introduces Traits to SelectorQuery to avoid a lot of code duplication between the queryFirst / queryAll cases. The code was duplicated in r155068 because this code is hot and we wanted to get rid of the if(firstMatchOnly) checks at runtime and stop using a Vector for the queryFirst() case. By using Traits, we can avoid the duplication while maintaining performance. The if(firstMatchOnly) checks are now optimized out by the compiler because the condition is a static const variable. Also, we use a Vector for the result only in the queryAll case, not in the queryFirst one. This patch also drops the SingleNodeList class and handles the single traverse root case separately to avoid causing regressions in QueryFirst() now that the code is shared between QueryFirst() / QueryAll(). We also now use templates to handle the different simple node list types so that isEmpty() / next() no longer need to be virtual which is performance-positive. Running the performance tests, I see the following results on Linux Desktop: - Parser/query-selector-all-attribute-complex: +4% - Parser/query-selector-all-attribute: +4% - Parser/query-selector-all-deep: +4% - Parser/query-selector-all-id-deep: +15% - Parser/query-selector-all-id-last: +15% - The rest is within noise, no major regression or improvement. This CL is based on the following WebKit commit by <benjamin@webkit.org>;: http://trac.webkit.org/changeset/154370 R=esprehn, eseidel BUG=336078 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=165679

Patch Set 1 #

Patch Set 2 : Rename methods #

Total comments: 11

Patch Set 3 : Use references #

Patch Set 4 : Take Adam's feedback into consideration #

Unified diffs Side-by-side diffs Delta from patch set Stats (+152 lines, -253 lines) Patch
M Source/core/dom/SelectorQuery.h View 1 2 3 2 chunks +21 lines, -11 lines 0 comments Download
M Source/core/dom/SelectorQuery.cpp View 1 2 3 7 chunks +131 lines, -242 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
Inactive
Second crack at This. This time with a bit more refactoring to avoid regressing the ...
6 years, 11 months ago (2014-01-20 04:14:10 UTC) #1
Inactive
ping review?
6 years, 11 months ago (2014-01-23 14:44:09 UTC) #2
esprehn
I'm not sure the templates really improve readability, but I guess this is okay since ...
6 years, 11 months ago (2014-01-23 18:26:34 UTC) #3
Inactive
Adamk, tasak, any comment / concern? https://codereview.chromium.org/142513003/diff/2/Source/core/dom/SelectorQuery.cpp File Source/core/dom/SelectorQuery.cpp (right): https://codereview.chromium.org/142513003/diff/2/Source/core/dom/SelectorQuery.cpp#newcode45 Source/core/dom/SelectorQuery.cpp:45: ALWAYS_INLINE static void ...
6 years, 11 months ago (2014-01-23 21:07:51 UTC) #4
adamk
https://codereview.chromium.org/142513003/diff/2/Source/core/dom/SelectorQuery.cpp File Source/core/dom/SelectorQuery.cpp (right): https://codereview.chromium.org/142513003/diff/2/Source/core/dom/SelectorQuery.cpp#newcode95 Source/core/dom/SelectorQuery.cpp:95: class ClassElementList { This and the above are nearly ...
6 years, 11 months ago (2014-01-23 21:16:13 UTC) #5
Inactive
https://codereview.chromium.org/142513003/diff/2/Source/core/dom/SelectorQuery.cpp File Source/core/dom/SelectorQuery.cpp (right): https://codereview.chromium.org/142513003/diff/2/Source/core/dom/SelectorQuery.cpp#newcode95 Source/core/dom/SelectorQuery.cpp:95: class ClassElementList { On 2014/01/23 21:16:13, adamk wrote: > ...
6 years, 11 months ago (2014-01-23 21:22:10 UTC) #6
Inactive
I took all of adamk's feedback into consideration. Please pay particular attention to the ClassRootNodeList ...
6 years, 11 months ago (2014-01-23 21:53:56 UTC) #7
adamk
lgtm
6 years, 11 months ago (2014-01-23 22:25:18 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ch.dumez@samsung.com/142513003/150001
6 years, 11 months ago (2014-01-23 23:31:12 UTC) #9
commit-bot: I haz the power
6 years, 11 months ago (2014-01-24 01:31:08 UTC) #10
Message was sent while issue was closed.
Change committed as 165679

Powered by Google App Engine
This is Rietveld 408576698