diff options
author | François Dumont <fdumont@gcc.gnu.org> | 2012-02-06 20:19:44 +0000 |
---|---|---|
committer | François Dumont <fdumont@gcc.gnu.org> | 2012-02-06 20:19:44 +0000 |
commit | 74345dec226a46b8c7095fbc4c62474cb1e86bff (patch) | |
tree | 0088c6eec6bede2a2e18376a5815c02d951c71f5 | |
parent | cb406914ff01074b3a859dedf0aeb4cd07edd93e (diff) | |
download | gcc-74345dec226a46b8c7095fbc4c62474cb1e86bff.zip gcc-74345dec226a46b8c7095fbc4c62474cb1e86bff.tar.gz gcc-74345dec226a46b8c7095fbc4c62474cb1e86bff.tar.bz2 |
2012-02-06 François Dumont <fdumont@gcc.gnu.org>
* include/debug/safe_iterator.h
(_Safe_iterator::_M_before_dereferenceable): Avoid the expensive
creation of a _Safe_iterator instance to do the check.
From-SVN: r183941
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/safe_iterator.h | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 799be7c..95a9a18 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2012-02-06 François Dumont <fdumont@gcc.gnu.org> + + * include/debug/safe_iterator.h + (_Safe_iterator::_M_before_dereferenceable): Avoid the expensive + creation of a _Safe_iterator instance to do the check. + 2012-02-05 Jonathan Wakely <jwakely.gcc@gmail.com> PR libstdc++/52104 diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index 016ec7b..e7cfe9c 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -380,8 +380,12 @@ namespace __gnu_debug bool _M_before_dereferenceable() const { - _Self __it = *this; - return __it._M_incrementable() && (++__it)._M_dereferenceable(); + if (this->_M_incrementable()) + { + _Iterator __base = base(); + return ++__base != _M_get_sequence()->_M_base().end(); + } + return false; } /// Is the iterator incrementable? |