This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: debug safe iterator patch
- From: François Dumont <frs dot dumont at gmail dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 06 Feb 2012 21:21:50 +0100
- Subject: Re: debug safe iterator patch
- References: <4F2EBC77.404@gmail.com> <4F2EBCD1.6000908@oracle.com>
Attached patch applied
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.
François
On 02/05/2012 06:30 PM, Paolo Carlini wrote:
On 02/05/2012 06:29 PM, François Dumont wrote:
Hi
Here is a small performance patch for the debug mode. Nothing
urgent, just tell me if I can apply it on trunk at the moment.
It impacts only debug-mode, thus it's pretty safe. If you tested it
check-debug I guess you can commit it to mainline even now.
Thanks,
Paolo.
Index: include/debug/safe_iterator.h
===================================================================
--- include/debug/safe_iterator.h (revision 183913)
+++ include/debug/safe_iterator.h (working copy)
@@ -380,8 +380,12 @@
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?