]> 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>
Wed, 26 Sep 2012 05:44:56 +0000 (15:44 +1000)
commit00d65d9ccc689a3e97f5c93a7b33edf5b5bc407a
tree196214097b67bcf73f2b2111a1abf087da59c0e4
parentac0224794dfefabdddbe1d5074d79888f202be23
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