BIND 10 trac2750, updated. 05b3886971fb003b0bbd735975bbbf0c38a1970c [2750] Introduce getSibling() again as a static function

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Sep 5 14:26:06 UTC 2013


The branch, trac2750 has been updated
       via  05b3886971fb003b0bbd735975bbbf0c38a1970c (commit)
       via  151a2b857e77b32b10c007e9a37f37ddcfb03b8b (commit)
      from  a47c17e54da2b08afb9dae8f46a97ac3a5e5bda0 (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 05b3886971fb003b0bbd735975bbbf0c38a1970c
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Sep 5 19:55:41 2013 +0530

    [2750] Introduce getSibling() again as a static function

commit 151a2b857e77b32b10c007e9a37f37ddcfb03b8b
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Sep 5 19:45:39 2013 +0530

    [2750] Use std::max()

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

Summary of changes:
 src/lib/datasrc/memory/domaintree.h |   32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index 14faaf9..99607ca 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -584,6 +584,24 @@ private:
         }
     }
 
+    /// \brief Access sibling node as bare pointer.
+    ///
+    /// A sibling node is defined as the parent's other child. It exists
+    /// at the same level as child. Note that child can be NULL here,
+    /// which is why this is a static function.
+    ///
+    /// \return the sibling node if one exists, NULL otherwise.
+    static DomainTreeNode<T>* getSibling(DomainTreeNode<T>* parent,
+                                         DomainTreeNode<T>* child)
+    {
+        if (!parent) {
+            return (NULL);
+        }
+
+        return ((parent->getLeft() == child) ?
+                parent->getRight() : parent->getLeft());
+    }
+
     /// \brief Access uncle node as bare pointer.
     ///
     /// An uncle node is defined as the parent node's sibling. It exists
@@ -2582,8 +2600,8 @@ DomainTree<T>::removeRebalance
         // A sibling node is defined as the parent's other child. It
         // exists at the same level as child. Note that child can be
         // NULL here.
-        DomainTreeNode<T>* sibling = (parent->getLeft() == child) ?
-            parent->getRight() : parent->getLeft();
+        DomainTreeNode<T>* sibling =
+            DomainTreeNode<T>::getSibling(parent, child);
 
         // NOTE #1: Understand this clearly. We are here only because in
         // the path through parent--child, a BLACK node was removed,
@@ -2629,8 +2647,7 @@ DomainTree<T>::removeRebalance
 
             // Re-compute child's sibling due to the tree adjustment
             // above.
-            sibling = (parent->getLeft() == child) ?
-                parent->getRight() : parent->getLeft();
+            sibling = DomainTreeNode<T>::getSibling(parent, child);
         }
 
         // NOTE #3: sibling still cannot be NULL here as parent--child
@@ -2767,8 +2784,7 @@ DomainTree<T>::removeRebalance
             }
             // Re-compute child's sibling due to the tree adjustment
             // above.
-            sibling = (parent->getLeft() == child) ?
-                parent->getRight() : parent->getLeft();
+            sibling = DomainTreeNode<T>::getSibling(parent, child);
         }
 
         // NOTE #7: sibling cannot be NULL here as even if the sibling
@@ -2927,10 +2943,10 @@ DomainTree<T>::getHeightHelper(const DomainTreeNode<T>* node) const {
     const size_t dl = getHeightHelper(node->getLeft());
     const size_t dr = getHeightHelper(node->getRight());
 
-    const size_t this_height = (dl > dr) ? (dl + 1) : (dr + 1);
+    const size_t this_height = std::max(dl + 1, dr + 1);
     const size_t down_height = getHeightHelper(node->getDown());
 
-    return ((this_height > down_height) ? this_height : down_height);
+    return (std::max(this_height, down_height));
 }
 
 template <typename T>



More information about the bind10-changes mailing list