Avoid unnecessary HashTable resizing during copy construction.

We do know the final table size, so reserve its size before starting
to copy over. Thereby avoiding intermediate table allocations.

R=esprehn
BUG=

Review-Url: https://codereview.chromium.org/2715473004
Cr-Commit-Position: refs/heads/master@{#452060}
diff --git a/third_party/WebKit/Source/wtf/HashTable.h b/third_party/WebKit/Source/wtf/HashTable.h
index dc707ef..2d9b5f8 100644
--- a/third_party/WebKit/Source/wtf/HashTable.h
+++ b/third_party/WebKit/Source/wtf/HashTable.h
@@ -1827,12 +1827,13 @@
       m_stats(HashTableStatsPtr<Allocator>::copy(other.m_stats))
 #endif
 {
+  if (other.size())
+    reserveCapacityForSize(other.size());
   // Copy the hash table the dumb way, by adding each element to the new
   // table.  It might be more efficient to copy the table slots, but it's not
   // clear that efficiency is needed.
-  const_iterator end = other.end();
-  for (const_iterator it = other.begin(); it != end; ++it)
-    add(*it);
+  for (const auto& element : other)
+    add(element);
 }
 
 template <typename Key,