BIND 10 trac2182, updated. 862b15fc77654a9baf86106b26932335a50e22c4 [2182] Simplify code further

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Aug 3 07:13:43 UTC 2012


The branch, trac2182 has been updated
       via  862b15fc77654a9baf86106b26932335a50e22c4 (commit)
      from  823c4a966326683eb0065cffe8fa2e219662d6a7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 862b15fc77654a9baf86106b26932335a50e22c4
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Aug 3 12:35:13 2012 +0530

    [2182] Simplify code further

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/rbtree.h |   47 ++++++++++++++++++----------------------------
 1 file changed, 18 insertions(+), 29 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/rbtree.h b/src/lib/datasrc/rbtree.h
index 2d3c178..2ec5347 100644
--- a/src/lib/datasrc/rbtree.h
+++ b/src/lib/datasrc/rbtree.h
@@ -1346,38 +1346,27 @@ template <typename T>
 void
 RBTree<T>::deleteHelper(util::MemorySegment& mem_sgmt, RBNode<T>* root) {
     while (root != NULL) {
-        // Walk to the left-most node under the root node.
-        while (root->getLeft() != NULL) {
+        // If there is a left, right or down node, walk into it and
+        // iterate.
+        if (root->getLeft() != NULL) {
+            RBNode<T>* node = root;
             root = root->getLeft();
-        }
-
-        // If there is a right node, walk into that one and repeat from
-        // start.
-        if (root->getRight() != NULL) {
+            node->left_ = NULL;
+        } else if (root->getRight() != NULL) {
+            RBNode<T>* node = root;
             root = root->getRight();
+            node->right_ = NULL;
+        } else if (root->getDown() != NULL) {
+            RBNode<T>* node = root;
+            root = root->getDown();
+            node->down_ = NULL;
         } else {
-            // If there is a down node, walk into that one and repeat
-            // from start.
-            if (root->getDown() != NULL) {
-                root = root->getDown();
-            } else {
-                // There are no left, right or down nodes, so we can
-                // free this one and go back to its parent.
-                RBNode<T>* node = root;
-                root = root->getParent();
-                if (root != NULL) {
-                    if (root->getRight() == node) {
-                        root->right_ = NULL;
-                    } else if (root->getLeft() == node) {
-                        root->left_ = NULL;
-                    } else {
-                        root->down_ = NULL;
-                    }
-                }
-
-                RBNode<T>::destroy(mem_sgmt, node);
-                --node_count_;
-            }
+            // There are no left, right or down nodes, so we can
+            // free this one and go back to its parent.
+            RBNode<T>* node = root;
+            root = root->getParent();
+            RBNode<T>::destroy(mem_sgmt, node);
+            --node_count_;
         }
     }
 }



More information about the bind10-changes mailing list