[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] rbtree: remove redundant if()-condition in rb_erase()



commit bd9cc37a040425551b6e5fe0dea87623635aca3e
Author:     Wolfram Strepp <wstrepp@xxxxxx>
AuthorDate: Wed Dec 20 18:00:49 2017 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Dec 20 18:00:49 2017 +0100

    rbtree: remove redundant if()-condition in rb_erase()
    
    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 <wstrepp@xxxxxx>
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    [Linux commit 4b324126e0c6c3a5080ca3ec0981e8766ed6f1ee]
    
    Ported to Xen.
    
    Signed-off-by: Praveen Kumar <kpraveen.lkml@xxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/rbtree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/common/rbtree.c b/xen/common/rbtree.c
index 167ebfd..62e6387 100644
--- a/xen/common/rbtree.c
+++ b/xen/common/rbtree.c
@@ -250,15 +250,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;
        }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.