Reset safe iterator state only if needed

Message ID 954323a6-e5eb-80b3-901f-99b058107aa3@gmail.com
State New
Headers show
Series
  • Reset safe iterator state only if needed
Related show

Commit Message

François Dumont June 7, 2018, 5:45 a.m.
We reset safe iterator state a lot, quite annoying when debugging.

Comitted as trivial.

2018-06-07  François Dumont  <fdumont@gcc.gnu.org>

     * src/c++11/debug.cc
     (_Safe_iterator_base::_M_detach()): Reset state only if needed.
     (_Safe_iterator_base::_M_detach_single()): Likewise.
     (_Safe_local_iterator_base::_M_detach()): Reset state only if needed.
     (_Safe_local_iterator_base::_M_detach_single()): Likewise.

Patch

diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
index d20725c..f7249a3 100644
--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -379,9 +379,10 @@  namespace __gnu_debug
   _M_detach()
   {
     if (_M_sequence)
-      _M_sequence->_M_detach(this);
-
-    _M_reset();
+      {
+	_M_sequence->_M_detach(this);
+	_M_reset();
+      }
   }
 
   void
@@ -389,9 +390,10 @@  namespace __gnu_debug
   _M_detach_single() throw ()
   {
     if (_M_sequence)
-      _M_sequence->_M_detach_single(this);
-
-    _M_reset();
+      {
+	_M_sequence->_M_detach_single(this);
+	_M_reset();
+      }
   }
 
   void
@@ -462,9 +464,10 @@  namespace __gnu_debug
   _M_detach()
   {
     if (_M_sequence)
-      _M_get_container()->_M_detach_local(this);
-
-    _M_reset();
+      {
+	_M_get_container()->_M_detach_local(this);
+	_M_reset();
+      }
   }
 
   void
@@ -472,9 +475,10 @@  namespace __gnu_debug
   _M_detach_single() throw ()
   {
     if (_M_sequence)
-      _M_get_container()->_M_detach_local_single(this);
-
-    _M_reset();
+      {
+	_M_get_container()->_M_detach_local_single(this);
+	_M_reset();
+      }
   }
 
   void