Chromium Code Reviews| Index: base/id_map.h |
| diff --git a/base/id_map.h b/base/id_map.h |
| index 74fb8d0b596cb7e1b0d758ad4e8ddfc3eb2b0103..9d67f1830e9c90a5159dad8d2edeb83b0b212bd0 100644 |
| --- a/base/id_map.h |
| +++ b/base/id_map.h |
| @@ -17,18 +17,6 @@ |
| #include "base/macros.h" |
| #include "base/sequence_checker.h" |
| -// Ownership semantics: |
| -// - OwnPointer means we store a unique_ptr that owns the object (so the |
| -// object is deleted in Remove() and during destruction). |
| -// - ExternalPointer means we store a raw pointer and don't own the object |
| - |
| -// TODO (http://crbug.com/647091): eliminate this enum, replace OwnPointer |
| -// mode in callsites with IDMap<unique_ptr<T>> |
| -enum IDMapOwnershipSemantics { |
| - IDMapExternalPointer, |
| - IDMapOwnPointer |
| -}; |
| - |
| // This object maintains a list of IDs that can be quickly converted to |
| // pointers to objects. It is implemented as a hash table, optimized for |
| // relatively small data sets (in the common case, there will be exactly one |
| @@ -40,16 +28,13 @@ enum IDMapOwnershipSemantics { |
| // |
| // This class does not have a virtual destructor, do not inherit from it when |
|
danakj
2016/11/30 23:02:21
This comment doesn't quite make sense anymore. Doe
rlanday
2016/12/01 00:50:07
Yeah it looks like nothing inherits from this
|
| // ownership semantics are set to own because pointers will leak. |
| -template <typename T, |
| - IDMapOwnershipSemantics OS = IDMapExternalPointer, |
| - typename K = int32_t> |
| +template <typename V, typename K = int32_t> |
|
danakj
2016/11/30 23:02:21
Maybe worth a comment now saying that the values (
rlanday
2016/12/01 00:50:07
Ok, that's a good point
|
| class IDMap { |
| public: |
| using KeyType = K; |
| private: |
| - using V = typename std:: |
| - conditional<OS == IDMapExternalPointer, T*, std::unique_ptr<T>>::type; |
| + using T = typename std::remove_reference<decltype(*V())>::type; |
| using HashTable = base::hash_map<KeyType, V>; |
| public: |
| @@ -149,9 +134,7 @@ class IDMap { |
| template<class ReturnType> |
| class Iterator { |
| public: |
| - Iterator(IDMap<T, OS, K>* map) |
| - : map_(map), |
| - iter_(map_->data_.begin()) { |
| + Iterator(IDMap<V, K>* map) : map_(map), iter_(map_->data_.begin()) { |
| Init(); |
| } |
| @@ -215,7 +198,7 @@ class IDMap { |
| } |
| } |
| - IDMap<T, OS, K>* map_; |
| + IDMap<V, K>* map_; |
| typename HashTable::const_iterator iter_; |
| }; |