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

Unified Diff: base/task/cancelable_task_tracker.h

Issue 2830093003: Replace uses of hash_map in //base (Closed)
Patch Set: iOS 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 | « base/stl_util.h ('k') | base/task/cancelable_task_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task/cancelable_task_tracker.h
diff --git a/base/task/cancelable_task_tracker.h b/base/task/cancelable_task_tracker.h
index ef5f163d44c826c27bc6da2c67fcfdf64c240c67..baf841d906faa74e3e18df56a92cf8f15114d439 100644
--- a/base/task/cancelable_task_tracker.h
+++ b/base/task/cancelable_task_tracker.h
@@ -43,7 +43,7 @@
#include "base/base_export.h"
#include "base/bind.h"
#include "base/callback.h"
-#include "base/containers/hash_tables.h"
+#include "base/containers/small_map.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/post_task_and_reply_with_result_internal.h"
@@ -142,7 +142,11 @@ class BASE_EXPORT CancelableTaskTracker {
void Track(TaskId id, CancellationFlag* flag);
void Untrack(TaskId id);
- hash_map<TaskId, CancellationFlag*> task_flags_;
+ // Typically the number of tasks are 0-2 and occationally 3-4. But since
+ // this is a general API that could be used in unexpected ways, use a
+ // small_map instead of a flat_map to avoid falling over if there are many
+ // tasks.
+ small_map<std::map<TaskId, CancellationFlag*>, 4> task_flags_;
TaskId next_id_;
SequenceChecker sequence_checker_;
« no previous file with comments | « base/stl_util.h ('k') | base/task/cancelable_task_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698