summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__hash_table
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-04-16 00:23:12 +0000
committerEric Fiselier <eric@efcs.ca>2016-04-16 00:23:12 +0000
commit500886841dadba249d8a95f04b2f72eb1c188606 (patch)
tree718c584bc390a08e88d96439bf267fb4e8e0eefa /libcxx/include/__hash_table
parent50154d4ec401043c58e5c74367fc63e6e9c7647d (diff)
downloadbcm5719-llvm-500886841dadba249d8a95f04b2f72eb1c188606.tar.gz
bcm5719-llvm-500886841dadba249d8a95f04b2f72eb1c188606.zip
Teach map/unordered_map how to optimize 'emplace(Key, T)'.
In cases where emplace is called with two arguments and the first one matches the key_type we can Key to check for duplicates before allocating. This patch expands on work done by dexonsmith@apple.com. llvm-svn: 266498
Diffstat (limited to 'libcxx/include/__hash_table')
-rw-r--r--libcxx/include/__hash_table11
1 files changed, 11 insertions, 0 deletions
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 2ea1a305720..13ab928e16f 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -1056,6 +1056,17 @@ public:
return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
__can_extract_key<_Pp, key_type>());
}
+
+ template <class _First, class _Second>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<
+ __can_extract_map_key<_First, key_type, __container_value_type>::value,
+ pair<iterator, bool>
+ >::type __emplace_unique(_First&& __f, _Second&& __s) {
+ return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
+ _VSTD::forward<_Second>(__s));
+ }
+
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __emplace_unique(_Args&&... __args) {
OpenPOWER on IntegriCloud