Commit 0545ebf2 by François Dumont

re PR libstdc++/53263 (priority_queue is very slow if -D_GLIBCXX_DEBUG is used)

2012-05-11  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/53263
	* include/debug/safe_iterator.h (__gnu_debug::__base): Move...
	* include/debug/functions.h: ... Here. Add debug function
	overloads to perform checks on normal iterators when possible.
	* include/debug/macros.h (__glibcxx_check_heap)
	(__glibcxx_check_heap_pred): Use __gnu_debug::__base on iterator range.

From-SVN: r187414
parent 06118b14
2012-05-11 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/53263
* include/debug/safe_iterator.h (__gnu_debug::__base): Move...
* include/debug/functions.h: ... Here. Add debug function
overloads to perform checks on normal iterators when possible.
* include/debug/macros.h (__glibcxx_check_heap)
(__glibcxx_check_heap_pred): Use __gnu_debug::__base on iterator range.
2012-05-10 DJ Delorie <dj@redhat.com>
* include/bits/random.tcc (seed_seq::generate): Cast max()
......
......@@ -296,7 +296,8 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
// Verify that the iterator range [_First, _Last) is a heap
#define __glibcxx_check_heap(_First,_Last) \
_GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \
_GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
__gnu_debug::__base(_Last)), \
_M_message(__gnu_debug::__msg_not_heap) \
._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last))
......@@ -304,7 +305,9 @@ _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \
/** Verify that the iterator range [_First, _Last) is a heap
w.r.t. the predicate _Pred. */
#define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
_GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last, _Pred), \
_GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
__gnu_debug::__base(_Last), \
_Pred), \
_M_message(__gnu_debug::__msg_not_heap_pred) \
._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last) \
......
......@@ -35,7 +35,6 @@
#include <debug/functions.h>
#include <debug/safe_base.h>
#include <bits/stl_pair.h>
#include <bits/stl_iterator_base_types.h> // for _Iter_base
#include <ext/type_traits.h>
namespace __gnu_debug
......@@ -714,37 +713,6 @@ namespace __gnu_debug
operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n,
const _Safe_iterator<_Iterator, _Sequence>& __i)
{ return __i + __n; }
// Helper struct to detect random access safe iterators.
template<typename _Iterator>
struct __is_safe_random_iterator
{
enum { __value = 0 };
typedef std::__false_type __type;
};
template<typename _Iterator, typename _Sequence>
struct __is_safe_random_iterator<_Safe_iterator<_Iterator, _Sequence> >
: std::__are_same<std::random_access_iterator_tag,
typename std::iterator_traits<_Iterator>::
iterator_category>
{ };
template<typename _Iterator>
struct _Siter_base
: std::_Iter_base<_Iterator, __is_safe_random_iterator<_Iterator>::__value>
{ };
/** Helper function to extract base iterator of random access safe iterator
in order to reduce performance impact of debug mode. Limited to random
access iterator because it is the only category for which it is possible
to check for correct iterators order in the __valid_range function
thanks to the < operator.
*/
template<typename _Iterator>
inline typename _Siter_base<_Iterator>::iterator_type
__base(_Iterator __it)
{ return _Siter_base<_Iterator>::_S_base(__it); }
} // namespace __gnu_debug
#include <debug/safe_iterator.tcc>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment