Further optimization of function rb_erase() in lib/rbtree.c
PATCH 3/3 Further optimization of function rb_erase() in lib/rbtree.c
Furthermore, notice that the initial checks:
if (!node->rb_left)
child = node->rb_right;
else if (!node->rb_right)
child = node->rb_left;
else
{
...
}guarantee that old->rb_right is set in the final else branch, therefore we can omit checking that again.
Signed-off-by Wolfram Strepp <[email protected]>
Signed-off-by Peter Zijlstra <[email protected]>
--- lib/rbtree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/rbtree.c +4 -4
@@ -257,15 +257,15 @@ void rb_erase(struct rb_node *node, struif (child)rb_set_parent (child, parent); parent->rb_left = child; + + node->rb_right = old->rb_right; +rb_set_parent (old->rb_right, node); } node->rb_parent_color = old->rb_parent_color; - node->rb_right = old->rb_right; node->rb_left = old->rb_left; -rb_set_parent (old->rb_left, node); -if (old->rb_right) -rb_set_parent (old->rb_right, node); + goto color; }
Signature · 1 line
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01