|
|
Created:
4 years, 5 months ago by Devlin Modified:
4 years, 5 months ago Reviewers:
lazyboy CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
Description[Extensions] Use rvalue references for SimpleFeature setters
Use rvalue references in SimpleFeature setters, rather than passing in a
const reference. In the generated code these setters are used in, the
values are all constructed in-place, so no copy is performed. This then
allows us to use move assignment operaters in SimpleFeature, thus avoiding
a copy.
BUG=280286
Committed: https://crrev.com/7a54e03af255cf365d7260324d9872aa94dd7ec1
Cr-Commit-Position: refs/heads/master@{#407334}
Patch Set 1 #
Total comments: 2
Patch Set 2 : rvalue #
Messages
Total messages: 22 (14 generated)
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
rdevlin.cronin@chromium.org changed reviewers: + lazyboy@chromium.org
I have one q. https://codereview.chromium.org/2172353002/diff/1/extensions/common/features/... File extensions/common/features/simple_feature.h (right): https://codereview.chromium.org/2172353002/diff/1/extensions/common/features/... extensions/common/features/simple_feature.h:111: void set_command_line_switch(std::string command_line_switch); (trying to understand stuff here, so this is probably naive q) Why not std::string&& command_line_switch if we know the param is constructed in place? The advantage of that is someone outside of generated code cannot use l-value anymore (including test): string s; ... set_command_line_switch(s) Now, style guide says "only use these (rvalue) to define move constructors and move assignment operators, and for perfect forwarding." So, that makes it no-go. Is this the only reason to not use it?
https://codereview.chromium.org/2172353002/diff/1/extensions/common/features/... File extensions/common/features/simple_feature.h (right): https://codereview.chromium.org/2172353002/diff/1/extensions/common/features/... extensions/common/features/simple_feature.h:111: void set_command_line_switch(std::string command_line_switch); On 2016/07/22 20:58:23, lazyboy wrote: > (trying to understand stuff here, so this is probably naive q) > Why not std::string&& command_line_switch if we know the param is constructed in > place? > The advantage of that is someone outside of generated code cannot use l-value > anymore (including test): > string s; > ... > set_command_line_switch(s) > > Now, style guide says "only use these (rvalue) to define move constructors and > move assignment operators, and for perfect forwarding." So, that makes it no-go. > Is this the only reason to not use it? Interesting idea! Yes, style is the only reason not to use it. WDYT? Worth breaking the style rule?
On 2016/07/22 21:27:35, Devlin wrote: > https://codereview.chromium.org/2172353002/diff/1/extensions/common/features/... > File extensions/common/features/simple_feature.h (right): > > https://codereview.chromium.org/2172353002/diff/1/extensions/common/features/... > extensions/common/features/simple_feature.h:111: void > set_command_line_switch(std::string command_line_switch); > On 2016/07/22 20:58:23, lazyboy wrote: > > (trying to understand stuff here, so this is probably naive q) > > Why not std::string&& command_line_switch if we know the param is constructed > in > > place? > > The advantage of that is someone outside of generated code cannot use l-value > > anymore (including test): > > string s; > > ... > > set_command_line_switch(s) > > > > Now, style guide says "only use these (rvalue) to define move constructors and > > move assignment operators, and for perfect forwarding." So, that makes it > no-go. > > Is this the only reason to not use it? > > Interesting idea! Yes, style is the only reason not to use it. WDYT? Worth > breaking the style rule? Think it's fine to break the rule for one-off cases like this (generated code only calls these functions other than tests). My preference would be to use rvalue if we can. If not, then keep it as is. dcheng@ or someone else might have better opinion here though. lgtm
On 2016/07/22 23:42:16, lazyboy wrote: > Think it's fine to break the rule for one-off cases like this (generated code > only calls these functions other than tests). > My preference would be to use rvalue if we can. If not, then keep it as is. SGTM. Let's try rvalue and see if anyone complains.
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== [Extensions] Use pass-by-value for SimpleFeature setters Use pass-by-value in SimpleFeature setters, rather than passing in a const reference. In the generated code these setters are used in, the values are all constructed in-place, so no copy is performed. This then allows us to std::move() the value into the SimpleFeature, thus avoiding a copy. BUG=280286 ========== to ========== [Extensions] Use rvalue references for SimpleFeature setters Use rvalue references in SimpleFeature setters, rather than passing in a const reference. In the generated code these setters are used in, the values are all constructed in-place, so no copy is performed. This then allows us to use move assignment operaters in SimpleFeature, thus avoiding a copy. BUG=280286 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by rdevlin.cronin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from lazyboy@chromium.org Link to the patchset: https://codereview.chromium.org/2172353002/#ps20001 (title: "rvalue")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== [Extensions] Use rvalue references for SimpleFeature setters Use rvalue references in SimpleFeature setters, rather than passing in a const reference. In the generated code these setters are used in, the values are all constructed in-place, so no copy is performed. This then allows us to use move assignment operaters in SimpleFeature, thus avoiding a copy. BUG=280286 ========== to ========== [Extensions] Use rvalue references for SimpleFeature setters Use rvalue references in SimpleFeature setters, rather than passing in a const reference. In the generated code these setters are used in, the values are all constructed in-place, so no copy is performed. This then allows us to use move assignment operaters in SimpleFeature, thus avoiding a copy. BUG=280286 ==========
Message was sent while issue was closed.
Committed patchset #2 (id:20001)
Message was sent while issue was closed.
Description was changed from ========== [Extensions] Use rvalue references for SimpleFeature setters Use rvalue references in SimpleFeature setters, rather than passing in a const reference. In the generated code these setters are used in, the values are all constructed in-place, so no copy is performed. This then allows us to use move assignment operaters in SimpleFeature, thus avoiding a copy. BUG=280286 ========== to ========== [Extensions] Use rvalue references for SimpleFeature setters Use rvalue references in SimpleFeature setters, rather than passing in a const reference. In the generated code these setters are used in, the values are all constructed in-place, so no copy is performed. This then allows us to use move assignment operaters in SimpleFeature, thus avoiding a copy. BUG=280286 Committed: https://crrev.com/7a54e03af255cf365d7260324d9872aa94dd7ec1 Cr-Commit-Position: refs/heads/master@{#407334} ==========
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/7a54e03af255cf365d7260324d9872aa94dd7ec1 Cr-Commit-Position: refs/heads/master@{#407334} |