BIND 10 trac2811_2, updated. ccdb49aa255c988dd3f03be21b9511794af288f5 [2811] Cleanup color testing code

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Aug 2 09:20:33 UTC 2013


The branch, trac2811_2 has been updated
       via  ccdb49aa255c988dd3f03be21b9511794af288f5 (commit)
      from  f36f677e841adddbaa762480d0cf8b961c098df1 (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 ccdb49aa255c988dd3f03be21b9511794af288f5
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Aug 2 14:49:45 2013 +0530

    [2811] Cleanup color testing code

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

Summary of changes:
 src/lib/datasrc/memory/domaintree.h |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index 3039118..3c8db0b 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -356,6 +356,16 @@ private:
         }
     }
 
+    /// \brief Returns if the node color is black
+    bool isBlack() const {
+        return (getColor() == BLACK);
+    }
+
+    /// \brief Returns if the node color is red
+    bool isRed() const {
+        return (!isBlack());
+    }
+
     /// \brief Sets the color of this node
     void setColor(const DomainTreeNodeColor color) {
         if (color == RED) {
@@ -1976,14 +1986,14 @@ DomainTree<T>::insertRebalance
         // subtree root to its children colored BLACK) but doesn't
         // change the red-black properties.
         DomainTreeNode<T>* parent = node->getParent();
-        if (parent->getColor() == DomainTreeNode<T>::BLACK) {
+        if (parent->isBlack()) {
             break;
         }
 
         DomainTreeNode<T>* uncle = node->getUncle();
         DomainTreeNode<T>* grandparent = node->getGrandParent();
 
-        if ((uncle != NULL) && (uncle->getColor() == DomainTreeNode<T>::RED)) {
+        if ((uncle != NULL) && uncle->isRed()) {
             // Case 3. Here, the node's parent is colored RED and the
             // uncle node is also RED. In this case, the grandparent
             // must be BLACK (due to existing red-black state).  We set
@@ -2171,7 +2181,7 @@ DomainTree<T>::dumpTreeHelper(std::ostream& os,
 
     indent(os, depth);
     os << node->getLabels() << " ("
-       << ((node->getColor() == DomainTreeNode<T>::BLACK) ? "black" : "red")
+       << (node->isBlack() ? "black" : "red")
        << ")";
     if (node->isEmpty()) {
         os << " [invisible]";
@@ -2235,7 +2245,7 @@ DomainTree<T>::dumpDotHelper(std::ostream& os,
     }
     os << "\"] [";
 
-    if (node->getColor() == DomainTreeNode<T>::RED) {
+    if (node->isRed()) {
         os << "color=red";
     } else {
         os << "color=black";



More information about the bind10-changes mailing list