Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: third_party/WebKit/Source/wtf/HashTable.h

Issue 2715473004: Avoid unnecessary HashTable resizing during copy construction. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/HashTable.h
diff --git a/third_party/WebKit/Source/wtf/HashTable.h b/third_party/WebKit/Source/wtf/HashTable.h
index dc707ef81fbc6f099030a89a3be1e43798a284c5..2d9b5f8d34b7e9bfd29b080e747bac509a6968cb 100644
--- a/third_party/WebKit/Source/wtf/HashTable.h
+++ b/third_party/WebKit/Source/wtf/HashTable.h
@@ -1827,12 +1827,13 @@ HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::
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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698