Consider adding move support to mojo::String |
||||
Issue descriptionContext: http://crrev.com/1709483002/ There are several places that pass mojo::String by value to Callback::Run(). That causes an extra copy of the string compare to a direct call to the bound function. With the move construction support of mojo::String, the copy is converted to just a move construction. So, IMO, mojo::String should be movable.
,
Mar 9 2016
Component :)
,
Mar 9 2016
I agree String should be movable. I think our plan is to replace any use of mojo::String with either std::string or WTF::String depending on whom we're generating bindings for. Will leave this bug open at least until that's sorted though.
,
Mar 9 2016
There is an issue in the current mojo bindings generator that strings in callback parameter lists are mapped to mojo::String passed-by-value incorrectly. I am planning to change that to const&, so that mojo::String is always passed by const& in mojom generated code. (In this pending CL, I have fixed the behavior for WTF::String and added a TODO for mojo::String: https://codereview.chromium.org/1751563002/) It doesn't hurt to add move support for mojo::String. I will do that. Ken: Now that we are not considering to replace mojo::Array/Map with std::vector/map (or scoped_ptr<std::vector>/scoped_ptr<std::map> in the nullable case), I think we may want to continue using mojo::String, rather than switching to std::string/scoped_ptr<std::string>? That way it is more consistent. I think mojo::String is pretty convenient for users and shouldn't have any perf impact. WDYT? Thanks!
,
Mar 9 2016
Ah SGTM
,
May 23 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/0b3918953d5aac5a179fca9370a17a801f45d874 commit 0b3918953d5aac5a179fca9370a17a801f45d874 Author: yzshen <yzshen@chromium.org> Date: Mon May 23 22:56:30 2016 Mojo C++ bindings: move support for mojo::String. BUG= 593220 Review-Url: https://codereview.chromium.org/2006823002 Cr-Commit-Position: refs/heads/master@{#395448} [modify] https://crrev.com/0b3918953d5aac5a179fca9370a17a801f45d874/mojo/public/cpp/bindings/string.h [modify] https://crrev.com/0b3918953d5aac5a179fca9370a17a801f45d874/mojo/public/cpp/bindings/tests/string_unittest.cc
,
May 23 2016
,
May 24 2016
Here's a vote for fewer string types. Unless you have very very convincing data that proves that using std::string cannot possibly work for you, please use std::string, like the rest of the codebase. |
||||
►
Sign in to add a comment |
||||
Comment 1 by thakis@chromium.org
, Mar 9 2016