From 33dc4890b707d46de356835cb0c51761172d73dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 7 Nov 2017 00:39:33 +0100 Subject: [PATCH] Avoid using external reference in loop to avoid aliasing pesimization. --- include/boost/intrusive/hashtable.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/boost/intrusive/hashtable.hpp b/include/boost/intrusive/hashtable.hpp index 6b1d5dd..58ccfa9 100644 --- a/include/boost/intrusive/hashtable.hpp +++ b/include/boost/intrusive/hashtable.hpp @@ -3370,7 +3370,7 @@ class hashtable_impl , size_type &found_bucket , size_type &cnt) const { - cnt = 0; + size_type internal_cnt = 0; //Let's see if the element is present siterator prev; @@ -3386,20 +3386,21 @@ class hashtable_impl //the same bucket bucket_type &b = this->priv_bucket_pointer()[n_bucket]; siterator it = to_return.first; - ++cnt; //At least one is found + ++internal_cnt; //At least one is found if(optimize_multikey){ to_return.second = ++(priv_last_in_group)(it); - cnt += boost::intrusive::iterator_distance(++it, to_return.second); + internal_cnt += boost::intrusive::iterator_distance(++it, to_return.second); } else{ siterator const bend = b.end(); while(++it != bend && this->priv_is_value_equal_to_key(this->priv_value_from_slist_node(it.pointed_node()), h, key, equal_func)){ - ++cnt; + ++internal_cnt; } to_return.second = it; } } + cnt = internal_cnt; return to_return; }