Chromium Code Reviews| Index: base/id_map.h |
| diff --git a/base/id_map.h b/base/id_map.h |
| index d171fb14c102cefc5b5ec332315e8a7303f86b9c..e6622c82737121cd30cc351870fe34e306fec001 100644 |
| --- a/base/id_map.h |
| +++ b/base/id_map.h |
| @@ -7,12 +7,14 @@ |
| #include <stddef.h> |
| #include <stdint.h> |
| +#include <map> |
| #include <memory> |
| #include <set> |
| #include <type_traits> |
| +#include <unordered_map> |
| #include <utility> |
| -#include "base/containers/hash_tables.h" |
| +#include "base/containers/flat_set.h" |
| #include "base/logging.h" |
| #include "base/macros.h" |
| #include "base/sequence_checker.h" |
| @@ -35,7 +37,10 @@ class IDMap final { |
| private: |
| using T = typename std::remove_reference<decltype(*V())>::type; |
| - using HashTable = base::hash_map<KeyType, V>; |
| + |
| + // Requires stable iterators so flat_map and small_map can't be used. |
| + // unordered_map is not used due to high memory overhead for small containers. |
| + using HashTable = std::unordered_map<KeyType, V>; |
|
Łukasz Anforowicz
2017/04/24 18:46:10
The declaration on previous line (using |std::unor
brettw
2017/04/25 23:32:36
I misunderstood the implementation and stable iter
Łukasz Anforowicz
2017/04/25 23:49:01
Thanks. I see that the CL switches |removed_ids_|
brettw
2017/04/26 20:51:57
IDMap is a template used in a bunch of places for
|
| public: |
| IDMap() : iteration_depth_(0), next_id_(1), check_on_null_data_(false) { |
| @@ -236,7 +241,7 @@ class IDMap final { |
| // Keep set of IDs that should be removed after the outermost iteration has |
| // finished. This way we manage to not invalidate the iterator when an element |
| // is removed. |
| - std::set<KeyType> removed_ids_; |
| + base::flat_set<KeyType> removed_ids_; |
|
Łukasz Anforowicz
2017/04/24 18:46:10
nit: I wonder if you could please expand the CL de
|
| // The next ID that we will return from Add() |
| KeyType next_id_; |