From afe294063ba8eb3ab28a2575fe5a219d6c29f2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 4 Jan 2022 00:34:33 +0100 Subject: [PATCH] Remove some forceinline attributes that might be counter-productive and add noexcept to others. --- .../boost/intrusive/avltree_algorithms.hpp | 4 +-- include/boost/intrusive/bstree_algorithms.hpp | 13 ++++------ .../intrusive/circular_list_algorithms.hpp | 18 ++++++------- .../intrusive/circular_slist_algorithms.hpp | 2 +- .../detail/common_slist_algorithms.hpp | 12 ++++----- include/boost/intrusive/hashtable.hpp | 26 +++++++------------ include/boost/intrusive/list.hpp | 4 +-- include/boost/intrusive/rbtree_algorithms.hpp | 4 +-- 8 files changed, 37 insertions(+), 46 deletions(-) diff --git a/include/boost/intrusive/avltree_algorithms.hpp b/include/boost/intrusive/avltree_algorithms.hpp index a6a059c..48b028c 100644 --- a/include/boost/intrusive/avltree_algorithms.hpp +++ b/include/boost/intrusive/avltree_algorithms.hpp @@ -46,14 +46,14 @@ struct avltree_node_cloner : base_t(f) {} - BOOST_INTRUSIVE_FORCEINLINE node_ptr operator()(node_ptr p) + node_ptr operator()(node_ptr p) { node_ptr n = base_t::get()(p); NodeTraits::set_balance(n, NodeTraits::get_balance(p)); return n; } - BOOST_INTRUSIVE_FORCEINLINE node_ptr operator()(node_ptr p) const + node_ptr operator()(node_ptr p) const { node_ptr n = base_t::get()(p); NodeTraits::set_balance(n, NodeTraits::get_balance(p)); diff --git a/include/boost/intrusive/bstree_algorithms.hpp b/include/boost/intrusive/bstree_algorithms.hpp index ecb070e..ac8a088 100644 --- a/include/boost/intrusive/bstree_algorithms.hpp +++ b/include/boost/intrusive/bstree_algorithms.hpp @@ -233,7 +233,7 @@ class bstree_algorithms : public bstree_algorithms_base //! Complexity: Constant time. //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static node_ptr root_node(const_node_ptr header) + BOOST_INTRUSIVE_FORCEINLINE static node_ptr root_node(const_node_ptr header) BOOST_NOEXCEPT { node_ptr p = node_traits::get_parent(header); return p ? p : detail::uncast(header); @@ -458,8 +458,6 @@ class bstree_algorithms : public bstree_algorithms_base //! the node, since no rebalancing and comparison is needed. Experimental function BOOST_INTRUSIVE_FORCEINLINE static void replace_node(node_ptr node_to_be_replaced, node_ptr new_node) BOOST_NOEXCEPT { - if(node_to_be_replaced == new_node) - return; replace_node(node_to_be_replaced, base_type::get_header(node_to_be_replaced), new_node); } @@ -479,8 +477,7 @@ class bstree_algorithms : public bstree_algorithms_base //! the node, since no rebalancing or comparison is needed. Experimental function static void replace_node(node_ptr node_to_be_replaced, node_ptr header, node_ptr new_node) BOOST_NOEXCEPT { - if(node_to_be_replaced == new_node) - return; + BOOST_ASSERT(node_to_be_replaced != new_node); //Update header if necessary if(node_to_be_replaced == NodeTraits::get_left(header)){ @@ -567,7 +564,7 @@ class bstree_algorithms : public bstree_algorithms_base //! Throws: Nothing. //! //! Nodes: If node is inserted in a tree, this function corrupts the tree. - BOOST_INTRUSIVE_FORCEINLINE static void init(node_ptr node) BOOST_NOEXCEPT + static void init(node_ptr node) BOOST_NOEXCEPT { NodeTraits::set_parent(node, node_ptr()); NodeTraits::set_left(node, node_ptr()); @@ -579,7 +576,7 @@ class bstree_algorithms : public bstree_algorithms_base //! Complexity: Constant. //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static bool inited(const_node_ptr node) + static bool inited(const_node_ptr node) { return !NodeTraits::get_parent(node) && !NodeTraits::get_left(node) && @@ -596,7 +593,7 @@ class bstree_algorithms : public bstree_algorithms_base //! Throws: Nothing. //! //! Nodes: If node is inserted in a tree, this function corrupts the tree. - BOOST_INTRUSIVE_FORCEINLINE static void init_header(node_ptr header) BOOST_NOEXCEPT + static void init_header(node_ptr header) BOOST_NOEXCEPT { NodeTraits::set_parent(header, node_ptr()); NodeTraits::set_left(header, header); diff --git a/include/boost/intrusive/circular_list_algorithms.hpp b/include/boost/intrusive/circular_list_algorithms.hpp index c8e57f9..8c886aa 100644 --- a/include/boost/intrusive/circular_list_algorithms.hpp +++ b/include/boost/intrusive/circular_list_algorithms.hpp @@ -67,7 +67,7 @@ class circular_list_algorithms //! Complexity: Constant //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static void init(node_ptr this_node) BOOST_NOEXCEPT + static void init(node_ptr this_node) BOOST_NOEXCEPT { const node_ptr null_node = node_ptr(); NodeTraits::set_next(this_node, null_node); @@ -91,7 +91,7 @@ class circular_list_algorithms //! Complexity: Constant //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static void init_header(node_ptr this_node) BOOST_NOEXCEPT + static void init_header(node_ptr this_node) BOOST_NOEXCEPT { NodeTraits::set_next(this_node, this_node); NodeTraits::set_previous(this_node, this_node); @@ -105,7 +105,7 @@ class circular_list_algorithms //! Complexity: Constant //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static bool unique(const_node_ptr this_node) BOOST_NOEXCEPT + static bool unique(const_node_ptr this_node) BOOST_NOEXCEPT { node_ptr next = NodeTraits::get_next(this_node); return !next || next == this_node; @@ -137,7 +137,7 @@ class circular_list_algorithms //! Complexity: Constant //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static node_ptr unlink(node_ptr this_node) BOOST_NOEXCEPT + static node_ptr unlink(node_ptr this_node) BOOST_NOEXCEPT { node_ptr next(NodeTraits::get_next(this_node)); node_ptr prev(NodeTraits::get_previous(this_node)); @@ -153,7 +153,7 @@ class circular_list_algorithms //! Complexity: Constant //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static void unlink(node_ptr b, node_ptr e) BOOST_NOEXCEPT + static void unlink(node_ptr b, node_ptr e) BOOST_NOEXCEPT { if (b != e) { node_ptr prevb(NodeTraits::get_previous(b)); @@ -169,7 +169,7 @@ class circular_list_algorithms //! Complexity: Constant //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static void link_before(node_ptr nxt_node, node_ptr this_node) BOOST_NOEXCEPT + static void link_before(node_ptr nxt_node, node_ptr this_node) BOOST_NOEXCEPT { node_ptr prev(NodeTraits::get_previous(nxt_node)); NodeTraits::set_previous(this_node, prev); @@ -188,7 +188,7 @@ class circular_list_algorithms //! Complexity: Constant //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static void link_after(node_ptr prev_node, node_ptr this_node) BOOST_NOEXCEPT + static void link_after(node_ptr prev_node, node_ptr this_node) BOOST_NOEXCEPT { node_ptr next(NodeTraits::get_next(prev_node)); NodeTraits::set_previous(this_node, prev_node); @@ -433,14 +433,14 @@ class circular_list_algorithms } private: - BOOST_INTRUSIVE_FORCEINLINE static void swap_prev(node_ptr this_node, node_ptr other_node) BOOST_NOEXCEPT + static void swap_prev(node_ptr this_node, node_ptr other_node) BOOST_NOEXCEPT { node_ptr temp(NodeTraits::get_previous(this_node)); NodeTraits::set_previous(this_node, NodeTraits::get_previous(other_node)); NodeTraits::set_previous(other_node, temp); } - BOOST_INTRUSIVE_FORCEINLINE static void swap_next(node_ptr this_node, node_ptr other_node) BOOST_NOEXCEPT + static void swap_next(node_ptr this_node, node_ptr other_node) BOOST_NOEXCEPT { node_ptr temp(NodeTraits::get_next(this_node)); NodeTraits::set_next(this_node, NodeTraits::get_next(other_node)); diff --git a/include/boost/intrusive/circular_slist_algorithms.hpp b/include/boost/intrusive/circular_slist_algorithms.hpp index 571ad8d..92dc5cc 100644 --- a/include/boost/intrusive/circular_slist_algorithms.hpp +++ b/include/boost/intrusive/circular_slist_algorithms.hpp @@ -223,7 +223,7 @@ class circular_slist_algorithms //! Complexity: Linear to the number of elements in the circular list //! //! Throws: Nothing. - BOOST_INTRUSIVE_FORCEINLINE static void unlink(node_ptr this_node) BOOST_NOEXCEPT + static void unlink(node_ptr this_node) BOOST_NOEXCEPT { if(NodeTraits::get_next(this_node)) base_t::unlink_after(get_previous_node(this_node)); diff --git a/include/boost/intrusive/detail/common_slist_algorithms.hpp b/include/boost/intrusive/detail/common_slist_algorithms.hpp index bc0d6b8..1d5413b 100644 --- a/include/boost/intrusive/detail/common_slist_algorithms.hpp +++ b/include/boost/intrusive/detail/common_slist_algorithms.hpp @@ -55,16 +55,16 @@ class common_slist_algorithms BOOST_INTRUSIVE_FORCEINLINE static void init(node_ptr this_node) BOOST_NOEXCEPT { NodeTraits::set_next(this_node, node_ptr()); } - BOOST_INTRUSIVE_FORCEINLINE static bool unique(const_node_ptr this_node) + static bool unique(const_node_ptr this_node) BOOST_NOEXCEPT { node_ptr next = NodeTraits::get_next(this_node); return !next || next == this_node; } - BOOST_INTRUSIVE_FORCEINLINE static bool inited(const_node_ptr this_node) + BOOST_INTRUSIVE_FORCEINLINE static bool inited(const_node_ptr this_node) BOOST_NOEXCEPT { return !NodeTraits::get_next(this_node); } - BOOST_INTRUSIVE_FORCEINLINE static void unlink_after(node_ptr prev_node) BOOST_NOEXCEPT + static void unlink_after(node_ptr prev_node) BOOST_NOEXCEPT { const_node_ptr this_node(NodeTraits::get_next(prev_node)); NodeTraits::set_next(prev_node, NodeTraits::get_next(this_node)); @@ -73,20 +73,20 @@ class common_slist_algorithms BOOST_INTRUSIVE_FORCEINLINE static void unlink_after(node_ptr prev_node, node_ptr last_node) BOOST_NOEXCEPT { NodeTraits::set_next(prev_node, last_node); } - BOOST_INTRUSIVE_FORCEINLINE static void link_after(node_ptr prev_node, node_ptr this_node) BOOST_NOEXCEPT + static void link_after(node_ptr prev_node, node_ptr this_node) BOOST_NOEXCEPT { NodeTraits::set_next(this_node, NodeTraits::get_next(prev_node)); NodeTraits::set_next(prev_node, this_node); } - BOOST_INTRUSIVE_FORCEINLINE static void incorporate_after(node_ptr bp, node_ptr b, node_ptr be) + static void incorporate_after(node_ptr bp, node_ptr b, node_ptr be) BOOST_NOEXCEPT { node_ptr p(NodeTraits::get_next(bp)); NodeTraits::set_next(bp, b); NodeTraits::set_next(be, p); } - static void transfer_after(node_ptr bp, node_ptr bb, node_ptr be) + static void transfer_after(node_ptr bp, node_ptr bb, node_ptr be) BOOST_NOEXCEPT { if (bp != bb && bp != be && bb != be) { node_ptr next_b = NodeTraits::get_next(bb); diff --git a/include/boost/intrusive/hashtable.hpp b/include/boost/intrusive/hashtable.hpp index 5baeaac..e2d0c9e 100644 --- a/include/boost/intrusive/hashtable.hpp +++ b/include/boost/intrusive/hashtable.hpp @@ -130,7 +130,7 @@ struct prime_list_holder } template //sizeof(SizeType) > sizeof(std::size_t) - static BOOST_INTRUSIVE_FORCEINLINE SizeType suggested_upper_bucket_count_dispatch(SizeType n, detail::true_) + static SizeType suggested_upper_bucket_count_dispatch(SizeType n, detail::true_) { std::size_t const c = n > std::size_t(-1) ? std::size_t(-1) @@ -139,7 +139,7 @@ struct prime_list_holder } template //sizeof(SizeType) > sizeof(std::size_t) - static BOOST_INTRUSIVE_FORCEINLINE SizeType suggested_lower_bucket_count_dispatch(SizeType n, detail::true_) + static SizeType suggested_lower_bucket_count_dispatch(SizeType n, detail::true_) { std::size_t const c = n > std::size_t(-1) ? std::size_t(-1) @@ -148,7 +148,7 @@ struct prime_list_holder } template - static BOOST_INTRUSIVE_FORCEINLINE SizeType suggested_upper_bucket_count_dispatch(SizeType n, detail::false_) + static SizeType suggested_upper_bucket_count_dispatch(SizeType n, detail::false_) { std::size_t const c = suggested_upper_bucket_count_impl(static_cast(n)); return truncate_size_type(c, detail::bool_<(sizeof(SizeType) < sizeof(std::size_t))>()); @@ -156,7 +156,7 @@ struct prime_list_holder } template - static BOOST_INTRUSIVE_FORCEINLINE SizeType suggested_lower_bucket_count_dispatch(SizeType n, detail::false_) + static SizeType suggested_lower_bucket_count_dispatch(SizeType n, detail::false_) { std::size_t const c = suggested_lower_bucket_count_impl(static_cast(n)); return truncate_size_type(c, detail::bool_<(sizeof(SizeType) < sizeof(std::size_t))>()); @@ -445,9 +445,7 @@ struct group_functions } BOOST_INTRUSIVE_FORCEINLINE static node_ptr next_group_if_first_in_group(node_ptr ptr) - { - return node_traits::get_next(group_traits::get_next(ptr)); - } + { return node_traits::get_next(group_traits::get_next(ptr)); } BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_first_in_group(node_ptr n, detail::false_) { return n; } @@ -458,7 +456,7 @@ struct group_functions static void insert_in_group(node_ptr, node_ptr, false_) {} - BOOST_INTRUSIVE_FORCEINLINE static node_ptr split_group(node_ptr const new_first_in_group) + static node_ptr split_group(node_ptr const new_first_in_group) { node_ptr const first((get_first_in_group)(new_first_in_group, detail::true_())); if(first != new_first_in_group){ @@ -525,10 +523,10 @@ BOOST_INTRUSIVE_FORCEINLINE std::size_t hash_to_bucket(std::size_t hash_value, s { return hash_value & (bucket_cnt - 1); } template -BOOST_INTRUSIVE_FORCEINLINE std::size_t hash_to_bucket_split(std::size_t hash_value, std::size_t bucket_cnt, std::size_t split) +std::size_t hash_to_bucket_split(std::size_t hash_value, std::size_t bucket_cnt, std::size_t split) { std::size_t bucket_number = detail::hash_to_bucket(hash_value, bucket_cnt, detail::bool_()); - if(Incremental) + BOOST_IF_CONSTEXPR(Incremental) bucket_number -= static_cast(bucket_number >= split)*(bucket_cnt/2); return bucket_number; } @@ -1242,9 +1240,7 @@ struct bucket_hash_equal_tcached_begin_ = this->bucket_hash_type::priv_invalid_bucket(); } BOOST_INTRUSIVE_FORCEINLINE void priv_swap_cache(bucket_hash_equal_t &other) - { - ::boost::adl_move_swap(this->cached_begin_, other.cached_begin_); - } + { ::boost::adl_move_swap(this->cached_begin_, other.cached_begin_); } siterator priv_begin() const { @@ -1476,9 +1472,7 @@ struct hashdata_internal //public functions BOOST_INTRUSIVE_FORCEINLINE SizeType split_count() const BOOST_NOEXCEPT - { - return this->priv_split_traits().get_size(); - } + { return this->priv_split_traits().get_size(); } BOOST_INTRUSIVE_FORCEINLINE iterator iterator_to(reference value) BOOST_NOEXCEPT { diff --git a/include/boost/intrusive/list.hpp b/include/boost/intrusive/list.hpp index 01d7381..17ce241 100644 --- a/include/boost/intrusive/list.hpp +++ b/include/boost/intrusive/list.hpp @@ -548,7 +548,7 @@ class list_impl //! Complexity: Constant. //! //! Note: Does not affect the validity of iterators and references. - BOOST_INTRUSIVE_FORCEINLINE void swap(list_impl& other) BOOST_NOEXCEPT + void swap(list_impl& other) BOOST_NOEXCEPT { node_algorithms::swap_nodes(this->get_root_node(), other.get_root_node()); this->priv_size_traits().swap(other.priv_size_traits()); @@ -1363,7 +1363,7 @@ class list_impl BOOST_INTRUSIVE_INVARIANT_ASSERT(this->priv_size_traits().get_size() == node_count); } - BOOST_INTRUSIVE_FORCEINLINE friend bool operator==(const list_impl &x, const list_impl &y) + friend bool operator==(const list_impl &x, const list_impl &y) { if(constant_time_size && x.size() != y.size()){ return false; diff --git a/include/boost/intrusive/rbtree_algorithms.hpp b/include/boost/intrusive/rbtree_algorithms.hpp index f8aba45..4457dc6 100644 --- a/include/boost/intrusive/rbtree_algorithms.hpp +++ b/include/boost/intrusive/rbtree_algorithms.hpp @@ -54,7 +54,7 @@ struct rbtree_node_cloner : base_t(f) {} - BOOST_INTRUSIVE_FORCEINLINE node_ptr operator()(node_ptr p) + node_ptr operator()(node_ptr p) { node_ptr n = base_t::get()(p); NodeTraits::set_color(n, NodeTraits::get_color(p)); @@ -273,7 +273,7 @@ class rbtree_algorithms #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED //! @copydoc ::boost::intrusive::bstree_algorithms::init_header(node_ptr) - BOOST_INTRUSIVE_FORCEINLINE static void init_header(node_ptr header) BOOST_NOEXCEPT + static void init_header(node_ptr header) BOOST_NOEXCEPT { bstree_algo::init_header(header); NodeTraits::set_color(header, NodeTraits::red());