From 54187ba442e16df7346acc8ba68f80ce3239e6b0 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 11 Nov 2011 15:31:01 +0100 Subject: [PATCH] core/rbtree: remove redundant if()-condition in rb_erase() See kernel commit 4b324126e0c6c3a5080ca3ec0981e8766ed6f1ee ---- 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 Signed-off-by: Peter Zijlstra Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds ---- Signed-off-by: Sylvain Munaut --- src/rbtree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rbtree.c b/src/rbtree.c index afbdca646..4e7c0f3a8 100644 --- a/src/rbtree.c +++ b/src/rbtree.c @@ -248,15 +248,15 @@ void rb_erase(struct rb_node *node, struct rb_root *root) if (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; }