[WK2] Reserve Vector capacity in VectorArgumentCoder<false, T, inlineCapacity>::decode()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Aug 2015 05:01:51 +0000 (05:01 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Aug 2015 05:01:51 +0000 (05:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147619

Reviewed by Andreas Kling.

Reserve Vector capacity in VectorArgumentCoder<false, T, inlineCapacity>::decode()
as we know the size of the Vector in advance.

* Platform/IPC/ArgumentCoders.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/Platform/IPC/ArgumentCoders.h

index 85506ee..49f2a6e 100644 (file)
@@ -1,3 +1,15 @@
+2015-08-03  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Reserve Vector capacity in VectorArgumentCoder<false, T, inlineCapacity>::decode()
+        https://bugs.webkit.org/show_bug.cgi?id=147619
+
+        Reviewed by Andreas Kling.
+
+        Reserve Vector capacity in VectorArgumentCoder<false, T, inlineCapacity>::decode()
+        as we know the size of the Vector in advance.
+
+        * Platform/IPC/ArgumentCoders.h:
+
 2015-08-03  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
 
         [CoordinatedGraphics] Rearrange uses of USE_COORDINATED_GRAPHICS_MULTIPROCESS
index 9838202..de65ff3 100644 (file)
@@ -164,15 +164,15 @@ template<typename T, size_t inlineCapacity> struct VectorArgumentCoder<false, T,
             return false;
 
         Vector<T, inlineCapacity> tmp;
+        tmp.reserveInitialCapacity(size);
         for (size_t i = 0; i < size; ++i) {
             T element;
             if (!decoder.decode(element))
                 return false;
             
-            tmp.append(WTF::move(element));
+            tmp.uncheckedAppend(WTF::move(element));
         }
 
-        tmp.shrinkToFit();
         vector.swap(tmp);
         return true;
     }