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

Unified Diff: base/containers/flat_set.h

Issue 2690853009: base: Add comments warning about using insert() a lot on flat_set. (Closed)
Patch Set: flatset-comment: . 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: base/containers/flat_set.h
diff --git a/base/containers/flat_set.h b/base/containers/flat_set.h
index 21334ebe098177f1810f95846e44200846604155..ae444c2c8e21c38ebec295ee023a365b84b3e057 100644
--- a/base/containers/flat_set.h
+++ b/base/containers/flat_set.h
@@ -42,6 +42,9 @@ namespace base {
// * Copying and iterating.
// * Set operations (union/intersect etc).
//
+// Prefer to build a new flat_set from a std::vector (or similar) instead of
+// calling insert() repeatedly, which would have O(size^2) complexity.
+//
// TODO(dyaroshev): develop standalone benchmarks to find performance boundaries
// for different types of sets crbug.com/682215.
//
@@ -189,6 +192,9 @@ class flat_set {
// Insertion of one element can take O(size). See the Notes section in the
// class comments on why we do not currently implement range insertion.
// Capacity of flat_set grows in an implementation-defined manner.
+ //
+ // NOTE: Prefer to build a new flat_set from a std::vector (or similar)
+ // instead of calling insert() repeatedly.
std::pair<iterator, bool> insert(const value_type& val);
std::pair<iterator, bool> insert(value_type&& val);
« 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