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

Issue 2879493003: Check if value changed when setting nested fields in ComputedStyleBase. (Closed)

Created:
3 years, 7 months ago by shend
Modified:
3 years, 7 months ago
CC:
blink-reviews, chromium-reviews
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. For example, the setter for the 'left' property might look like: void SetLeft(const Length& v) { if (surround_data_->left_ != v) surround_data_->Access()->left_ = v; } As we can see, we only call Access() when the values are different, potentially saving a copy. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/darrnshn/47e96b81c2ade55cb337fd658f0d6785/revisions BUG=628043 Review-Url: https://codereview.chromium.org/2879493003 Cr-Commit-Position: refs/heads/master@{#470873} Committed: https://chromium.googlesource.com/chromium/src/+/e8e5df6b838075a0dc6e584853f1f795ac5af0b3

Patch Set 1 #

Patch Set 2 : Rebase #

Patch Set 3 : Address comments #

Total comments: 2

Patch Set 4 : Rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+22 lines, -8 lines) Patch
M third_party/WebKit/Source/build/scripts/templates/fields/base.tmpl View 3 chunks +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl View 1 2 3 1 chunk +7 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/build/scripts/templates/fields/field.tmpl View 1 2 chunks +10 lines, -1 line 0 comments Download
M third_party/WebKit/Source/build/scripts/templates/fields/monotonic_flag.tmpl View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 37 (24 generated)
shend
Hi Naina, PTAL
3 years, 7 months ago (2017-05-11 00:45:26 UTC) #9
nainar
lgtm. nit: to make it clearer maybe add an example inline in the CL desciption?
3 years, 7 months ago (2017-05-11 01:02:16 UTC) #10
shend
done. Eddy, PTAL :)
3 years, 7 months ago (2017-05-11 01:50:18 UTC) #13
shend
Redirecting to Alan. PTAL :)
3 years, 7 months ago (2017-05-11 01:53:25 UTC) #15
alancutter (OOO until 2018)
Looking at the generated code this looks very wrong: > surround_data_->border_bottom_left_radius_ == std::move(v)
3 years, 7 months ago (2017-05-11 04:03:24 UTC) #18
shend
On 2017/05/11 at 04:03:24, alancutter wrote: > Looking at the generated code this looks very ...
3 years, 7 months ago (2017-05-11 04:11:11 UTC) #19
alancutter (OOO until 2018)
On 2017/05/11 at 04:11:11, shend wrote: > On 2017/05/11 at 04:03:24, alancutter wrote: > > ...
3 years, 7 months ago (2017-05-11 04:14:51 UTC) #20
shend
On 2017/05/11 at 04:14:51, alancutter wrote: > On 2017/05/11 at 04:11:11, shend wrote: > > ...
3 years, 7 months ago (2017-05-11 05:35:02 UTC) #23
alancutter (OOO until 2018)
https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl File third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl (right): https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl#newcode13 third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl:13: {{field.name}} = std::move({{value}}); Should this be referencing v instead ...
3 years, 7 months ago (2017-05-11 05:56:38 UTC) #25
shend
https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl File third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl (right): https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl#newcode13 third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl:13: {{field.name}} = std::move({{value}}); On 2017/05/11 at 05:56:38, alancutter wrote: ...
3 years, 7 months ago (2017-05-11 06:03:00 UTC) #27
alancutter (OOO until 2018)
lgtm
3 years, 7 months ago (2017-05-11 06:26:51 UTC) #29
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/2879493003/60001
3 years, 7 months ago (2017-05-11 08:08:38 UTC) #34
commit-bot: I haz the power
3 years, 7 months ago (2017-05-11 08:13:50 UTC) #37
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as
https://chromium.googlesource.com/chromium/src/+/e8e5df6b838075a0dc6e584853f1...

Powered by Google App Engine
This is Rietveld 408576698