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 <wal...@google.com> --- 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/