summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/debug
diff options
context:
space:
mode:
authorfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-28 20:52:13 +0000
committerfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-28 20:52:13 +0000
commitec812219bbf38cbfd1505733c1c473ddb3edb729 (patch)
tree8545a60d6c1448b1ab73d4df8cbd0068780d2f08 /libstdc++-v3/include/debug
parentb433697be05a6f133ac71ed30e7312270c65344b (diff)
downloadppe42-gcc-ec812219bbf38cbfd1505733c1c473ddb3edb729.tar.gz
ppe42-gcc-ec812219bbf38cbfd1505733c1c473ddb3edb729.zip
2013-01-28 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable_policy.h (_Local_iterator_base): Use _Hashtable_ebo_helper to embed functors into the local_iterator when necessary. Pass information about functors involved in hash code by copy. * include/bits/hashtable.h (__cache_default): Do not cache for builtin integral types unless the hash functor is not noexcept qualified or is not default constructible. Adapt static assertions and local iterator instantiations. * include/debug/unordered_set (std::__debug::unordered_set<>::erase): Detect local iterators to invalidate using contained node rather than generating a dummy local_iterator instance. (std::__debug::unordered_multiset<>::erase): Likewise. * include/debug/unordered_map (std::__debug::unordered_map<>::erase): Likewise. (std::__debug::unordered_multimap<>::erase): Likewise. * testsuite/performance/23_containers/insert_erase/41975.cc: Test std::tr1 and std versions of unordered_set regardless of any macro. Add test on default cache behavior. * testsuite/performance/23_containers/insert/54075.cc: Likewise. * testsuite/23_containers/unordered_set/instantiation_neg.cc: Adapt line number. * testsuite/23_containers/unordered_set/ not_default_constructible_hash_neg.cc: New. * testsuite/23_containers/unordered_set/buckets/swap.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/debug')
-rw-r--r--libstdc++-v3/include/debug/unordered_map62
-rw-r--r--libstdc++-v3/include/debug/unordered_set62
2 files changed, 24 insertions, 100 deletions
diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map
index 284450fc7d8..a826b0190d5 100644
--- a/libstdc++-v3/include/debug/unordered_map
+++ b/libstdc++-v3/include/debug/unordered_map
@@ -361,10 +361,9 @@ namespace __debug
{
this->_M_invalidate_if([__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
size_type __bucket_count = this->bucket_count();
_Base::erase(__victim);
_M_check_rehashed(__bucket_count);
@@ -380,10 +379,9 @@ namespace __debug
_Base_const_iterator __victim = __it.base();
this->_M_invalidate_if([__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_const_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
size_type __bucket_count = this->bucket_count();
_Base_iterator __next = _Base::erase(__it.base());
_M_check_rehashed(__bucket_count);
@@ -407,10 +405,9 @@ namespace __debug
._M_iterator(__last, "last"));
this->_M_invalidate_if([__tmp](_Base_const_iterator __it)
{ return __it == __tmp; });
- _Base_const_local_iterator __local_tmp = _S_to_local(__tmp);
this->_M_invalidate_local_if(
- [__local_tmp](_Base_const_local_iterator __it)
- { return __it == __local_tmp; });
+ [__tmp](_Base_const_local_iterator __it)
+ { return __it._M_cur == __tmp._M_cur; });
}
size_type __bucket_count = this->bucket_count();
_Base_iterator __next = _Base::erase(__first.base(), __last.base());
@@ -449,22 +446,6 @@ namespace __debug
if (__prev_count != this->bucket_count())
_M_invalidate_locals();
}
-
- static _Base_local_iterator
- _S_to_local(_Base_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_local_iterator(__it._M_cur, 0, 0);
- }
-
- static _Base_const_local_iterator
- _S_to_local(_Base_const_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_const_local_iterator(__it._M_cur, 0, 0);
- }
};
template<typename _Key, typename _Tp, typename _Hash,
@@ -807,10 +788,9 @@ namespace __debug
{
this->_M_invalidate_if([__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
_Base::erase(__victim++);
++__ret;
}
@@ -825,10 +805,9 @@ namespace __debug
_Base_const_iterator __victim = __it.base();
this->_M_invalidate_if([__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_const_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
size_type __bucket_count = this->bucket_count();
_Base_iterator __next = _Base::erase(__it.base());
_M_check_rehashed(__bucket_count);
@@ -852,10 +831,9 @@ namespace __debug
._M_iterator(__last, "last"));
this->_M_invalidate_if([__tmp](_Base_const_iterator __it)
{ return __it == __tmp; });
- _Base_const_local_iterator __local_tmp = _S_to_local(__tmp);
this->_M_invalidate_local_if(
- [__local_tmp](_Base_const_local_iterator __it)
- { return __it == __local_tmp; });
+ [__tmp](_Base_const_local_iterator __it)
+ { return __it._M_cur == __tmp._M_cur; });
}
size_type __bucket_count = this->bucket_count();
_Base_iterator __next = _Base::erase(__first.base(), __last.base());
@@ -894,22 +872,6 @@ namespace __debug
if (__prev_count != this->bucket_count())
_M_invalidate_locals();
}
-
- static _Base_local_iterator
- _S_to_local(_Base_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_local_iterator(__it._M_cur, 0, 0);
- }
-
- static _Base_const_local_iterator
- _S_to_local(_Base_const_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_const_local_iterator(__it._M_cur, 0, 0);
- }
};
template<typename _Key, typename _Tp, typename _Hash,
diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set
index 2fe71e4bb07..8e88addd87f 100644
--- a/libstdc++-v3/include/debug/unordered_set
+++ b/libstdc++-v3/include/debug/unordered_set
@@ -356,10 +356,9 @@ namespace __debug
this->_M_invalidate_if(
[__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
size_type __bucket_count = this->bucket_count();
_Base::erase(__victim);
_M_check_rehashed(__bucket_count);
@@ -376,10 +375,9 @@ namespace __debug
this->_M_invalidate_if(
[__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_const_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
size_type __bucket_count = this->bucket_count();
_Base_iterator __next = _Base::erase(__it.base());
_M_check_rehashed(__bucket_count);
@@ -404,10 +402,9 @@ namespace __debug
this->_M_invalidate_if(
[__tmp](_Base_const_iterator __it)
{ return __it == __tmp; });
- _Base_const_local_iterator __local_tmp = _S_to_local(__tmp);
this->_M_invalidate_local_if(
- [__local_tmp](_Base_const_local_iterator __it)
- { return __it == __local_tmp; });
+ [__tmp](_Base_const_local_iterator __it)
+ { return __it._M_cur == __tmp._M_cur; });
}
size_type __bucket_count = this->bucket_count();
_Base_iterator __next = _Base::erase(__first.base(),
@@ -448,22 +445,6 @@ namespace __debug
if (__prev_count != this->bucket_count())
_M_invalidate_locals();
}
-
- static _Base_local_iterator
- _S_to_local(_Base_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_local_iterator(__it._M_cur, 0, 0);
- }
-
- static _Base_const_local_iterator
- _S_to_local(_Base_const_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_const_local_iterator(__it._M_cur, 0, 0);
- }
};
template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
@@ -798,10 +779,9 @@ namespace __debug
{
this->_M_invalidate_if([__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
_Base::erase(__victim++);
++__ret;
}
@@ -815,10 +795,9 @@ namespace __debug
_Base_const_iterator __victim = __it.base();
this->_M_invalidate_if([__victim](_Base_const_iterator __it)
{ return __it == __victim; });
- _Base_const_local_iterator __local_victim = _S_to_local(__victim);
this->_M_invalidate_local_if(
- [__local_victim](_Base_const_local_iterator __it)
- { return __it == __local_victim; });
+ [__victim](_Base_const_local_iterator __it)
+ { return __it._M_cur == __victim._M_cur; });
return iterator(_Base::erase(__it.base()), this);
}
@@ -839,10 +818,9 @@ namespace __debug
._M_iterator(__last, "last"));
this->_M_invalidate_if([__tmp](_Base_const_iterator __it)
{ return __it == __tmp; });
- _Base_const_local_iterator __local_tmp = _S_to_local(__tmp);
this->_M_invalidate_local_if(
- [__local_tmp](_Base_const_local_iterator __it)
- { return __it == __local_tmp; });
+ [__tmp](_Base_const_local_iterator __it)
+ { return __it._M_cur == __tmp._M_cur; });
}
return iterator(_Base::erase(__first.base(),
__last.base()), this);
@@ -879,22 +857,6 @@ namespace __debug
if (__prev_count != this->bucket_count())
_M_invalidate_locals();
}
-
- static _Base_local_iterator
- _S_to_local(_Base_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_local_iterator(__it._M_cur, 0, 0);
- }
-
- static _Base_const_local_iterator
- _S_to_local(_Base_const_iterator __it)
- {
- // The returned local iterator will not be incremented so we don't
- // need to compute __it's node bucket
- return _Base_const_local_iterator(__it._M_cur, 0, 0);
- }
};
template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
OpenPOWER on IntegriCloud