New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593220 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Consider adding move support to mojo::String

Project Member Reported by tzik@chromium.org, Mar 9 2016

Issue description

Context: 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.

 
Cc: roc...@chromium.org
rockot, which labels cause mojo triage?
Cc: yzshen@chromium.org
Components: Internals>Mojo
Component :)
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.
Owner: yzshen@chromium.org
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!
Ah SGTM

Comment 7 by yzshen@chromium.org, May 23 2016

Status: Fixed (was: Available)

Comment 8 by thakis@chromium.org, 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