[PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 16 12:20:40 PDT 2016
EricWF added a comment.
Adding inline comments for the implementation. Comments on the tests to follow shortly.
================
Comment at: include/__hash_table:103
@@ -102,1 +102,3 @@
+template <class _ValTy, class _Key>
+struct __extract_key;
----------------
Could you make `__extract_key` behave the same way as `__can_extract_key` where we apply the `__uncvref<ValTy>` instead of expecting the user to?
================
Comment at: include/__hash_table:110
@@ +109,3 @@
+ : is_same<
+ typename remove_const<typename remove_reference<_ValTy>::type>::type,
+ _Key> {};
----------------
Assuming we can't be passed volatile types (I'll double check that). Then we should just use `is_same<_RawValTy, _Key>`
================
Comment at: include/__hash_table:113
@@ +112,3 @@
+template <class _Key>
+struct __extract_key<_Key, _Key> {
+ const _Key &operator()(const _Key &__key) { return __key; }
----------------
Please keep the `__can_extract_key` and `__extract_key` specializations together.
================
Comment at: include/__hash_table:124
@@ +123,3 @@
+};
+template <class _Key, class _Second>
+struct __extract_key<pair<const _Key, _Second>, _Key> {
----------------
Add a newline before this class definition.
http://reviews.llvm.org/D16360
More information about the cfe-commits
mailing list