[PATCH] D16792: unordered_map: Use __hash_table::__emplace_unique(), NFC

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 1 17:43:11 PST 2016

dexonsmith created this revision.
dexonsmith added a reviewer: EricWF.
dexonsmith added a subscriber: cfe-commits.

Instead of duplicating code in unordered_map::emplace(), use



Index: include/unordered_map
--- include/unordered_map
+++ include/unordered_map
@@ -922,7 +922,8 @@
     template <class... _Args>
-        pair<iterator, bool> emplace(_Args&&... __args);
+    pair<iterator, bool> emplace(_Args&&... __args)
+        {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
     template <class... _Args>
@@ -1474,18 +1475,6 @@
     return __h;
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class... _Args>
-pair<typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::iterator, bool>
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
-    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
-    if (__r.second)
-        __h.release();
-    return __r;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16792.46602.patch
Type: text/x-patch
Size: 1100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160202/999696e2/attachment.bin>

More information about the cfe-commits mailing list