]> git.karo-electronics.de Git - karo-tx-linux.git/commit
rbtree: handle 1-child recoloring in rb_erase() instead of rb_erase_color()
authorMichel Lespinasse <walken@google.com>
Fri, 7 Sep 2012 00:23:51 +0000 (10:23 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Sep 2012 05:36:21 +0000 (15:36 +1000)
commit31cba0d4baaea412e0065eca4a3a1479e8bb48f0
tree52e2beafe0253b40a331fd37e73d3b6e232bf899
parentca6057e32d7da81a6b112d8406cd5efe7496971b
rbtree: handle 1-child recoloring in rb_erase() instead of rb_erase_color()

An interesting observation for rb_erase() is that when a node has
exactly one child, the node must be black and the child must be red.
An interesting consequence is that removing such a node can be done by
simply replacing it with its child and making the child black,
which we can do efficiently in rb_erase(). __rb_erase_color() then
only needs to handle the no-childs case and can be modified accordingly.

Signed-off-by: Michel Lespinasse <walken@google.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/rbtree.c