diff options
author | Abseil Team <absl-team@google.com> | 2019-11-26 09:00:19 -0800 |
---|---|---|
committer | Gennadiy Rozental <rogeeff@google.com> | 2019-11-26 12:37:42 -0500 |
commit | 0514227d2547793b23e209809276375e41c76617 (patch) | |
tree | f2cfabd8a93bf4308eb62cad6e672d821bca0725 /absl/container/internal/btree_container.h | |
parent | 7f4fe64af80fe3c84db8ea938276c3690573c45e (diff) | |
download | abseil-0514227d2547793b23e209809276375e41c76617.tar.gz abseil-0514227d2547793b23e209809276375e41c76617.tar.bz2 abseil-0514227d2547793b23e209809276375e41c76617.zip |
Export of internal Abseil changes
--
2ba0e41a21fbdab36b2f4f3b0dd4b112bd788604 by Derek Mauro <dmauro@google.com>:
Remove the include of <intsafe.h>, which is missing on
some versions of MinGW. DWORD is easily replaced by uint32_t.
PiperOrigin-RevId: 282576177
--
238fd41114b3e83fcb91d2afe1e6dcce7cfd53b0 by Samuel Benzaquen <sbenza@google.com>:
Remove assertion in erase(iterator) that tries to use the comparator.
Add missing this-> qualifier.
Fix bug where node elements are not being destroyed properly.
PiperOrigin-RevId: 282427096
--
6b9446e3b38ed97451c010933e86a572ab659ab2 by Derek Mauro <dmauro@google.com>:
Improves/fixes feature detection in thread_identity
Only use ABSL_PER_THREAD_TLS_KEYWORD when it is supported (previously
on some platforms it evaluated to nothing, which completely breaks
everything), but prefer it to thread_local since benchmarks indicate
it is slightly faster in this critical code path.
Disable the calls to pthread_sigmask on MinGW where it is not
supported.
PiperOrigin-RevId: 282425291
GitOrigin-RevId: 2ba0e41a21fbdab36b2f4f3b0dd4b112bd788604
Change-Id: I34073ecbb4a43ad71f54161c136d88fc728888f1
Diffstat (limited to 'absl/container/internal/btree_container.h')
-rw-r--r-- | absl/container/internal/btree_container.h | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/absl/container/internal/btree_container.h b/absl/container/internal/btree_container.h index 726861d5..774412d9 100644 --- a/absl/container/internal/btree_container.h +++ b/absl/container/internal/btree_container.h @@ -296,9 +296,10 @@ class btree_set_container : public btree_container<Tree> { insert_return_type insert(node_type &&node) { if (!node) return {this->end(), false, node_type()}; std::pair<iterator, bool> res = - insert(std::move(params_type::element(CommonAccess::GetSlot(node)))); + this->tree_.insert_unique(params_type::key(CommonAccess::GetSlot(node)), + CommonAccess::GetSlot(node)); if (res.second) { - CommonAccess::Reset(&node); + CommonAccess::Destroy(&node); return {res.first, true, node_type()}; } else { return {res.first, false, std::move(node)}; @@ -308,8 +309,8 @@ class btree_set_container : public btree_container<Tree> { if (!node) return this->end(); std::pair<iterator, bool> res = this->tree_.insert_hint_unique( iterator(hint), params_type::key(CommonAccess::GetSlot(node)), - std::move(params_type::element(CommonAccess::GetSlot(node)))); - if (res.second) CommonAccess::Reset(&node); + CommonAccess::GetSlot(node)); + if (res.second) CommonAccess::Destroy(&node); return res.first; } @@ -323,7 +324,7 @@ class btree_set_container : public btree_container<Tree> { // Node extraction routines. template <typename K = key_type> node_type extract(const key_arg<K> &key) { - auto it = find(key); + auto it = this->find(key); return it == this->end() ? node_type() : extract(it); } using super_type::extract; @@ -523,24 +524,21 @@ class btree_multiset_container : public btree_container<Tree> { return this->tree_.insert_hint_multi( iterator(position), init_type(std::forward<Args>(args)...)); } - - private: - template <typename... Args> - iterator insert_node_helper(node_type &&node, Args &&... args) { + iterator insert(node_type &&node) { if (!node) return this->end(); iterator res = - insert(std::forward<Args>(args)..., - std::move(params_type::element(CommonAccess::GetSlot(node)))); - CommonAccess::Reset(&node); + this->tree_.insert_multi(params_type::key(CommonAccess::GetSlot(node)), + CommonAccess::GetSlot(node)); + CommonAccess::Destroy(&node); return res; } - - public: - iterator insert(node_type &&node) { - return insert_node_helper(std::move(node)); - } iterator insert(const_iterator hint, node_type &&node) { - return insert_node_helper(std::move(node), hint); + if (!node) return this->end(); + iterator res = this->tree_.insert_hint_multi( + iterator(hint), + std::move(params_type::element(CommonAccess::GetSlot(node)))); + CommonAccess::Destroy(&node); + return res; } // Deletion routines. @@ -553,7 +551,7 @@ class btree_multiset_container : public btree_container<Tree> { // Node extraction routines. template <typename K = key_type> node_type extract(const key_arg<K> &key) { - auto it = find(key); + auto it = this->find(key); return it == this->end() ? node_type() : extract(it); } using super_type::extract; |