summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-05-29 10:17:36 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-05-29 10:17:36 +0300
commitf5c3b1c637b4c7c98a9efbc1b99f825dbbe37a51 (patch)
tree784b97fe3d9cb59d15b87995464920052454f2cf
parent5cca4b3ab78ee964081c3eba6eb715fdf3ed4dbd (diff)
downloadunit-f5c3b1c637b4c7c98a9efbc1b99f825dbbe37a51.tar.gz
unit-f5c3b1c637b4c7c98a9efbc1b99f825dbbe37a51.tar.bz2
A small rbtree delete fixup optimization.
Setting node color to black is not required here because it is already black. Besides in the original algorithm the node pointer is discarded and the node is set to tree root just to quit the loop. Thanks to 洪志道 (Hong Zhi Dao).
-rw-r--r--src/nxt_rbtree.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nxt_rbtree.c b/src/nxt_rbtree.c
index 66ff3665..4a0f9c22 100644
--- a/src/nxt_rbtree.c
+++ b/src/nxt_rbtree.c
@@ -399,7 +399,7 @@ nxt_rbtree_delete_fixup(nxt_rbtree_t *tree, nxt_rbtree_node_t *node)
nxt_rbtree_left_rotate(parent);
- break;
+ return;
} else {
sibling = parent->left;
@@ -437,7 +437,7 @@ nxt_rbtree_delete_fixup(nxt_rbtree_t *tree, nxt_rbtree_node_t *node)
nxt_rbtree_right_rotate(parent);
- break;
+ return;
}
}