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

Unified Diff: components/safe_browsing_db/remote_database_manager.cc

Issue 2838163002: Use base::flat_set<> rather than std::set<> for ResourceType set (Closed)
Patch Set: Reserve the vector size upfront to reduce allocations Created 3 years, 8 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 | « components/safe_browsing_db/remote_database_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/remote_database_manager.cc
diff --git a/components/safe_browsing_db/remote_database_manager.cc b/components/safe_browsing_db/remote_database_manager.cc
index 2def386d5f8b885838ebcc49de2cc136c07e5532..153a4dfb88b47907608d4c2a37a4e5c29fc9cdc1 100644
--- a/components/safe_browsing_db/remote_database_manager.cc
+++ b/components/safe_browsing_db/remote_database_manager.cc
@@ -99,6 +99,10 @@ void RemoteSafeBrowsingDatabaseManager::ClientRequest::OnRequestDone(
// TODO(nparker): Add more tests for this class
RemoteSafeBrowsingDatabaseManager::RemoteSafeBrowsingDatabaseManager() {
+ // Avoid memory allocations growing the underlying vector. Although this
+ // usually wastes a bit of memory, it will still be less than the default
+ // vector allocation strategy.
+ resource_types_to_check_.reserve(content::RESOURCE_TYPE_LAST_TYPE + 1);
// Decide which resource types to check. These two are the minimum.
resource_types_to_check_.insert(content::RESOURCE_TYPE_MAIN_FRAME);
resource_types_to_check_.insert(content::RESOURCE_TYPE_SUB_FRAME);
« no previous file with comments | « components/safe_browsing_db/remote_database_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698