]> git.kernelconcepts.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, 28 Sep 2012 00:19:30 +0000 (10:19 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 8 Oct 2012 03:00:04 +0000 (14:00 +1100)
commit6f5dfe569e31542288f24c77c3f745cf748d4f68
treec7a7d388f32ed805a94b61267f37d949d7f0dcd6
parent2258d95b13fc75484bed5fd6c8248ab039134233
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