]> 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>
Wed, 26 Sep 2012 01:33:35 +0000 (11:33 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 27 Sep 2012 07:26:19 +0000 (17:26 +1000)
commit07e6dcc72e5eac99815c0bfffb4641b383173704
treecff3625ab6c6c0e0e398259428d2fdff60484f54
parent8fb072602515ee7cb48e358c0b65ac184a865252
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