[GTK][WK2] Move Vector objects into WebEditorClient::executePendingEditorCommands...
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Apr 2014 08:24:49 +0000 (08:24 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Apr 2014 08:24:49 +0000 (08:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131454

Reviewed by Carlos Garcia Campos.

* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::WebEditorClient::executePendingEditorCommands): Take a const reference of the Vector
object to avoid unnecessary copies. Also deploy two range-based for loops and efficiently move
the Editor::Command objects into the other Vector.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167116 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h
Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp

index ce676d4..9123623 100644 (file)
@@ -1,3 +1,16 @@
+2014-04-11  Zan Dobersek  <zdobersek@igalia.com>
+
+        [GTK][WK2] Move Vector objects into WebEditorClient::executePendingEditorCommands() invocations
+        https://bugs.webkit.org/show_bug.cgi?id=131454
+
+        Reviewed by Carlos Garcia Campos.
+
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+        (WebKit::WebEditorClient::executePendingEditorCommands): Take a const reference of the Vector
+        object to avoid unnecessary copies. Also deploy two range-based for loops and efficiently move
+        the Editor::Command objects into the other Vector.
+
 2014-04-10  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/16582465> [Cocoa] Avoid casts from CF types to unrelated Objective-C types
 2014-04-10  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/16582465> [Cocoa] Avoid casts from CF types to unrelated Objective-C types
index b2be26b..26b555e 100644 (file)
@@ -125,7 +125,7 @@ private:
 #endif
 
 #if PLATFORM(GTK)
 #endif
 
 #if PLATFORM(GTK)
-    bool executePendingEditorCommands(WebCore::Frame*, Vector<WTF::String>, bool);
+    bool executePendingEditorCommands(WebCore::Frame*, const Vector<WTF::String>&, bool);
     void getEditorCommandsForKeyEvent(const WebCore::KeyboardEvent*, Vector<WTF::String>&);
     void updateGlobalSelection(WebCore::Frame*);
 #endif
     void getEditorCommandsForKeyEvent(const WebCore::KeyboardEvent*, Vector<WTF::String>&);
     void updateGlobalSelection(WebCore::Frame*);
 #endif
index 0f17868..bfbb446 100644 (file)
@@ -47,19 +47,19 @@ void WebEditorClient::getEditorCommandsForKeyEvent(const KeyboardEvent* event, V
                                                 m_page->pageID(), std::chrono::milliseconds::max());
 }
 
                                                 m_page->pageID(), std::chrono::milliseconds::max());
 }
 
-bool WebEditorClient::executePendingEditorCommands(Frame* frame, Vector<WTF::String> pendingEditorCommands, bool allowTextInsertion)
+bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion)
 {
     Vector<Editor::Command> commands;
 {
     Vector<Editor::Command> commands;
-    for (size_t i = 0; i < pendingEditorCommands.size(); i++) {
-        Editor::Command command = frame->editor().command(pendingEditorCommands.at(i).utf8().data());
+    for (auto& commandString : pendingEditorCommands) {
+        Editor::Command command = frame->editor().command(commandString.utf8().data());
         if (command.isTextInsertion() && !allowTextInsertion)
             return false;
 
         if (command.isTextInsertion() && !allowTextInsertion)
             return false;
 
-        commands.append(command);
+        commands.append(std::move(command));
     }
 
     }
 
-    for (size_t i = 0; i < commands.size(); i++) {
-        if (!commands.at(i).execute())
+    for (auto& command : commands) {
+        if (!command.execute())
             return false;
     }
 
             return false;
     }