[njs] A small rbtree delete fixup optimization.

Igor Sysoev igor at sysoev.ru
Mon May 29 07:22:12 UTC 2017


details:   http://hg.nginx.org/njs/rev/c0bdd23e740e
branches:  
changeset: 345:c0bdd23e740e
user:      Igor Sysoev <igor at sysoev.ru>
date:      Mon May 29 10:17:36 2017 +0300
description:
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).

diffstat:

 nxt/nxt_rbtree.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r 7f1f3dcb278f -r c0bdd23e740e nxt/nxt_rbtree.c
--- a/nxt/nxt_rbtree.c	Sat May 27 18:02:09 2017 +0300
+++ b/nxt/nxt_rbtree.c	Mon May 29 10:17:36 2017 +0300
@@ -402,7 +402,7 @@ nxt_rbtree_delete_fixup(nxt_rbtree_t *tr
 
             nxt_rbtree_left_rotate(parent);
 
-            break;
+            return;
 
         } else {
             sibling = parent->left;
@@ -440,7 +440,7 @@ nxt_rbtree_delete_fixup(nxt_rbtree_t *tr
 
             nxt_rbtree_right_rotate(parent);
 
-            break;
+            return;
         }
     }
 


More information about the nginx-devel mailing list