In __rb_erase_color(), when the current node is red or when flipping the sibling's color, the parent is already known so we can use the more efficient rb_set_parent_color() function to set the desired color. Signed-off-by: Michel Lespinasse <walken@xxxxxxxxxx> --- lib/rbtree.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rbtree.c b/lib/rbtree.c index c956248..f8c1a75 100644 --- a/lib/rbtree.c +++ b/lib/rbtree.c @@ -29,8 +29,6 @@ #define rb_color(r) ((r)->rb_parent_color & 1) #define rb_is_red(r) (!rb_color(r)) #define rb_is_black(r) rb_color(r) -#define rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0) -#define rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0) static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p) { @@ -170,7 +168,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent, * and tree rotations as per one of the 4 cases below. */ if (node && rb_is_red(node)) { - rb_set_black(node); + rb_set_parent_color(node, parent, RB_BLACK); break; } else if (!parent) { break; @@ -190,7 +188,8 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent, tmp2 = sibling->rb_left; if (!tmp2 || rb_is_black(tmp2)) { /* Case 2 - sibling color flip */ - rb_set_red(sibling); + rb_set_parent_color(sibling, parent, + RB_RED); node = parent; parent = rb_parent(node); continue; @@ -230,7 +229,8 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent, tmp2 = sibling->rb_right; if (!tmp2 || rb_is_black(tmp2)) { /* Case 2 - sibling color flip */ - rb_set_red(sibling); + rb_set_parent_color(sibling, parent, + RB_RED); node = parent; parent = rb_parent(node); continue; -- 1.7.7.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>