This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Updated: [Patch] stl_tree.h: _Rb_tree_rebalance(): Add local variablefor grandparent and use const
- From: Gawain Bolton <gbolton at free dot fr>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sat, 05 Jul 2003 17:09:21 +0200
- Subject: Updated: [Patch] stl_tree.h: _Rb_tree_rebalance(): Add local variablefor grandparent and use const
- Reply-to: gp dot bolton at computer dot org
Here's an updated and minor patch for stl_tree.h. This patch is an
update of the original one posted previously:
http://gcc.gnu.org/ml/libstdc++/2003-04/msg00436.html
Tested on linux i686.
Cheers,
Gawain
2003-07-05 Gawain Bolton <gp.bolton@computer.org>
* include/bits/stl_tree.h: _Rb_tree_rebalance(): Add local
variable for grandparent and use const
Index: stl_tree.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libstdc++-v3/include/bits/stl_tree.h,v
retrieving revision 1.24
diff -u -r1.24 stl_tree.h
--- stl_tree.h 5 Jul 2003 04:05:35 -0000 1.24
+++ stl_tree.h 5 Jul 2003 15:05:52 -0000
@@ -265,9 +265,9 @@
{ return __x._M_node != __y._M_node; }
inline void
- _Rb_tree_rotate_left(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)
+ _Rb_tree_rotate_left(_Rb_tree_node_base* const __x, _Rb_tree_node_base*& __root)
{
- _Rb_tree_node_base* __y = __x->_M_right;
+ _Rb_tree_node_base* const __y = __x->_M_right;
__x->_M_right = __y->_M_left;
if (__y->_M_left !=0)
__y->_M_left->_M_parent = __x;
@@ -284,9 +284,9 @@
}
inline void
- _Rb_tree_rotate_right(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)
+ _Rb_tree_rotate_right(_Rb_tree_node_base* const __x, _Rb_tree_node_base*& __root)
{
- _Rb_tree_node_base* __y = __x->_M_left;
+ _Rb_tree_node_base* const __y = __x->_M_left;
__x->_M_left = __y->_M_right;
if (__y->_M_right != 0)
__y->_M_right->_M_parent = __x;
@@ -309,15 +309,17 @@
while (__x != __root
&& __x->_M_parent->_M_color == _S_red)
{
- if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left)
+ _Rb_tree_node_base* const __xpp = __x->_M_parent->_M_parent;
+
+ if (__x->_M_parent == __xpp->_M_left)
{
- _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right;
+ _Rb_tree_node_base* const __y = __xpp->_M_right;
if (__y && __y->_M_color == _S_red)
{
__x->_M_parent->_M_color = _S_black;
__y->_M_color = _S_black;
- __x->_M_parent->_M_parent->_M_color = _S_red;
- __x = __x->_M_parent->_M_parent;
+ __xpp->_M_color = _S_red;
+ __x = __xpp;
}
else
{
@@ -327,19 +329,19 @@
_Rb_tree_rotate_left(__x, __root);
}
__x->_M_parent->_M_color = _S_black;
- __x->_M_parent->_M_parent->_M_color = _S_red;
- _Rb_tree_rotate_right(__x->_M_parent->_M_parent, __root);
+ __xpp->_M_color = _S_red;
+ _Rb_tree_rotate_right(__xpp, __root);
}
}
else
{
- _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left;
+ _Rb_tree_node_base* const __y = __xpp->_M_left;
if (__y && __y->_M_color == _S_red)
{
__x->_M_parent->_M_color = _S_black;
__y->_M_color = _S_black;
- __x->_M_parent->_M_parent->_M_color = _S_red;
- __x = __x->_M_parent->_M_parent;
+ __xpp->_M_color = _S_red;
+ __x = __xpp;
}
else
{
@@ -349,8 +351,8 @@
_Rb_tree_rotate_right(__x, __root);
}
__x->_M_parent->_M_color = _S_black;
- __x->_M_parent->_M_parent->_M_color = _S_red;
- _Rb_tree_rotate_left(__x->_M_parent->_M_parent, __root);
+ __xpp->_M_color = _S_red;
+ _Rb_tree_rotate_left(__xpp, __root);
}
}
}
@@ -358,10 +360,10 @@
}
inline _Rb_tree_node_base*
- _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* __z,
- _Rb_tree_node_base*& __root,
- _Rb_tree_node_base*& __leftmost,
- _Rb_tree_node_base*& __rightmost)
+ _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
+ _Rb_tree_node_base*& __root,
+ _Rb_tree_node_base*& __leftmost,
+ _Rb_tree_node_base*& __rightmost)
{
_Rb_tree_node_base* __y = __z;
_Rb_tree_node_base* __x = 0;