Bug 131454 - [GTK][WK2] Move Vector objects into WebEditorClient::executePendingEditorCommands() invocations
Summary: [GTK][WK2] Move Vector objects into WebEditorClient::executePendingEditorComm...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-09 14:35 PDT by Zan Dobersek
Modified: 2014-04-11 01:25 PDT (History)
2 users (show)

See Also:


Attachments
Patch (3.12 KB, patch)
2014-04-09 14:43 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (2.37 KB, patch)
2014-04-10 22:43 PDT, Zan Dobersek
cgarcia: review+
cgarcia: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2014-04-09 14:35:35 PDT
[GTK][WK2] Move Vector objects into WebEditorClient::executePendingEditorCommands() invocations
Comment 1 Zan Dobersek 2014-04-09 14:43:58 PDT
Created attachment 228984 [details]
Patch
Comment 2 Martin Robinson 2014-04-09 16:33:13 PDT
Comment on attachment 228984 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=228984&action=review

> Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:50
>  bool WebEditorClient::executePendingEditorCommands(Frame* frame, Vector<WTF::String> pendingEditorCommands, bool allowTextInsertion)

It seems like this should either copy the contents or take a reference to pendingEditorCommands. If we don't mind stomping the contents of pendingEditorCommands a reference more straight-forward. If we do mind, we cannot use std::move, right?
Comment 3 Zan Dobersek 2014-04-10 00:56:04 PDT
Comment on attachment 228984 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=228984&action=review

>> Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:50
>>  bool WebEditorClient::executePendingEditorCommands(Frame* frame, Vector<WTF::String> pendingEditorCommands, bool allowTextInsertion)
> 
> It seems like this should either copy the contents or take a reference to pendingEditorCommands. If we don't mind stomping the contents of pendingEditorCommands a reference more straight-forward. If we do mind, we cannot use std::move, right?

We don't mind stomping the contents of that Vector, even if we don't stomp them in the end. But in WebEditorClient::handleKeyboardEvent() the Vector isn't used after the WebEditorClient::executePendingEditorCommands() call (whichever of the two is performed), so moving the object along into that invocation isn't harmful.

Passing in the Vector by reference would make sense if we'd use that Vector later in handleKeyboardEvent(), but we don't. There's nothing wrong with passing the object by reference, but it's not necessary. Hence the proposal to use std::move() and pass it by value.
Comment 4 Martin Robinson 2014-04-10 07:41:56 PDT
(In reply to comment #3)

> Passing in the Vector by reference would make sense if we'd use that Vector later in handleKeyboardEvent(), but we don't. There's nothing wrong with passing the object by reference, but it's not necessary. Hence the proposal to use std::move() and pass it by value.

It's slightly more efficient because you don't have to construct a new object and matches what we usually do in that situation.
Comment 5 Zan Dobersek 2014-04-10 22:42:42 PDT
(In reply to comment #4)
> (In reply to comment #3)
> 
> > Passing in the Vector by reference would make sense if we'd use that Vector later in handleKeyboardEvent(), but we don't. There's nothing wrong with passing the object by reference, but it's not necessary. Hence the proposal to use std::move() and pass it by value.
> 
> It's slightly more efficient because you don't have to construct a new object and matches what we usually do in that situation.

I see, WebEditorClient::executePendingEditorCommands() only reads from the Vector but doesn't store it, so taking the const reference of the Vector is indeed more intuitive.
Comment 6 Zan Dobersek 2014-04-10 22:43:08 PDT
Created attachment 229110 [details]
Patch
Comment 7 Carlos Garcia Campos 2014-04-10 23:40:13 PDT
Comment on attachment 229110 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229110&action=review

Please update also the header to fix the build.

> Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:50
> +bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion)

You need to update the header too.
Comment 8 Zan Dobersek 2014-04-11 01:21:42 PDT
Comment on attachment 229110 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229110&action=review

>> Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:50
>> +bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion)
> 
> You need to update the header too.

Heh, of course :>
Comment 9 Zan Dobersek 2014-04-11 01:25:55 PDT
Committed r167116: <http://trac.webkit.org/changeset/167116>