From: Igor Sysoev Date: Fri, 20 Jan 2017 13:10:48 +0000 (+0300) Subject: A small rbtree insert fixup optimization. X-Git-Tag: 0.1.8~1 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/%7B@url%7D?a=commitdiff_plain;h=c1efa5e66158d6dc816523a908a030731a0ec330;p=njs.git A small rbtree insert fixup optimization. Thanks to 洪志道 (Hong Zhi Dao). --- diff --git a/nxt/nxt_rbtree.c b/nxt/nxt_rbtree.c index 24cb4e6f..852317d4 100644 --- a/nxt/nxt_rbtree.c +++ b/nxt/nxt_rbtree.c @@ -135,8 +135,12 @@ nxt_rbtree_insert_fixup(nxt_rbtree_node_t *node) grandparent = parent->parent; grandparent->color = NXT_RBTREE_RED; nxt_rbtree_right_rotate(grandparent); - - continue; + /* + * nxt_rbtree_right_rotate() does not change node->parent + * color which is now black, so testing color is not required + * to return from function. + */ + return; } } else { @@ -156,7 +160,8 @@ nxt_rbtree_insert_fixup(nxt_rbtree_node_t *node) grandparent->color = NXT_RBTREE_RED; nxt_rbtree_left_rotate(grandparent); - continue; + /* See the comment in the symmetric branch above. */ + return; } }