BIND 10 master, updated. ac2c63f07c78ba94fb8b76ce1051a5810b97a99a bug #1749: Address review comments (from bug #1748)

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Mar 14 03:31:39 UTC 2012


The branch, master has been updated
       via  ac2c63f07c78ba94fb8b76ce1051a5810b97a99a (commit)
       via  02db7759b655b9eb3e5d4e750e5f5bf212e1157f (commit)
       via  1007c99c026d5d7f51a95061d25f59d621441b39 (commit)
       via  216b2e18c9811ec25dc99ae9b320140033e26a36 (commit)
       via  64eef65d27bf5310afa53cac418c18bc8a989b31 (commit)
      from  1af6565d9d5f789c82ececbf83ca725cf3208b3f (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 ac2c63f07c78ba94fb8b76ce1051a5810b97a99a
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Mar 13 09:18:49 2012 +0530

    bug #1749: Address review comments (from bug #1748)

commit 02db7759b655b9eb3e5d4e750e5f5bf212e1157f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Mar 13 09:15:22 2012 +0530

    bug #1748: Add one more testcase comparing a RRset with itself

commit 1007c99c026d5d7f51a95061d25f59d621441b39
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Mar 13 09:13:02 2012 +0530

    bug #1748: Change code to use a condition expression

commit 216b2e18c9811ec25dc99ae9b320140033e26a36
Author: Mukund Sivaraman <muks at isc.org>
Date:   Sun Mar 11 14:14:51 2012 +0530

    [1749] Implement a specialized RBNodeRRset::isSameKind()

commit 64eef65d27bf5310afa53cac418c18bc8a989b31
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Mar 9 12:29:23 2012 +0530

    [1748] Define AbstractRRset::isSameKind() and implement the default version

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

Summary of changes:
 src/lib/datasrc/rbnode_rrset.h                 |   14 ++++++++++++++
 src/lib/datasrc/tests/rbnode_rrset_unittest.cc |   17 +++++++++++++++++
 src/lib/dns/rrset.cc                           |   10 ++++++++++
 src/lib/dns/rrset.h                            |    8 ++++++++
 src/lib/dns/tests/rrset_unittest.cc            |   14 ++++++++++++++
 5 files changed, 63 insertions(+), 0 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/rbnode_rrset.h b/src/lib/datasrc/rbnode_rrset.h
index f687919..3e5d20a 100644
--- a/src/lib/datasrc/rbnode_rrset.h
+++ b/src/lib/datasrc/rbnode_rrset.h
@@ -127,6 +127,20 @@ public:
 
     virtual std::string toText() const;
 
+    virtual bool isSameKind(const AbstractRRset& other) const {
+        // This code is an optimisation for comparing
+        // RBNodeRRsets. However, in doing this optimisation,
+        // semantically the code is not "is same kind" but is instead
+        // "is identical object" in the case where RBNodeRRsets are compared.
+
+        const RBNodeRRset* rb = dynamic_cast<const RBNodeRRset*>(&other);
+        if (rb != NULL) {
+            return (this == rb);
+        } else {
+            return (AbstractRRset::isSameKind(other));
+        }
+    }
+
     virtual unsigned int toWire(
         isc::dns::AbstractMessageRenderer& renderer) const;
 
diff --git a/src/lib/datasrc/tests/rbnode_rrset_unittest.cc b/src/lib/datasrc/tests/rbnode_rrset_unittest.cc
index a46d9cf..c653f44 100644
--- a/src/lib/datasrc/tests/rbnode_rrset_unittest.cc
+++ b/src/lib/datasrc/tests/rbnode_rrset_unittest.cc
@@ -138,6 +138,23 @@ TEST_F(RBNodeRRsetTest, toText) {
     EXPECT_THROW(rrset_a_empty.toText(), EmptyRRset);
 }
 
+TEST_F(RBNodeRRsetTest, isSameKind) {
+    RBNodeRRset rrset_p(ConstRRsetPtr(new RRset(test_name, RRClass::IN(), RRType::A(), RRTTL(3600))));
+    RBNodeRRset rrset_q(ConstRRsetPtr(new RRset(test_name, RRClass::IN(), RRType::A(), RRTTL(3600))));
+    RRset rrset_w(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
+    RRset rrset_x(test_nsname, RRClass::IN(), RRType::A(), RRTTL(3600));
+    RRset rrset_y(test_name, RRClass::IN(), RRType::NS(), RRTTL(3600));
+    RRset rrset_z(test_name, RRClass::CH(), RRType::A(), RRTTL(3600));
+
+    EXPECT_TRUE(rrset_p.isSameKind(rrset_p));
+    EXPECT_FALSE(rrset_p.isSameKind(rrset_q));
+
+    EXPECT_TRUE(rrset_p.isSameKind(rrset_w));
+    EXPECT_FALSE(rrset_p.isSameKind(rrset_x));
+    EXPECT_FALSE(rrset_p.isSameKind(rrset_y));
+    EXPECT_FALSE(rrset_p.isSameKind(rrset_z));
+}
+
 // Note: although the next two tests are essentially the same and used common
 // test code, they use different test data: the MessageRenderer produces
 // compressed wire data whereas the OutputBuffer does not.
diff --git a/src/lib/dns/rrset.cc b/src/lib/dns/rrset.cc
index 776d49f..9a55f5f 100644
--- a/src/lib/dns/rrset.cc
+++ b/src/lib/dns/rrset.cc
@@ -113,6 +113,16 @@ AbstractRRset::toWire(AbstractMessageRenderer& renderer) const {
     return (rrs_written);
 }
 
+bool
+AbstractRRset::isSameKind(const AbstractRRset& other) const {
+  // Compare classes last as they're likely to be identical. Compare
+  // names late in the list too, as these are expensive. So we compare
+  // types first, names second and classes last.
+  return (getType() == other.getType() &&
+	  getName() == other.getName() &&
+	  getClass() == other.getClass());
+}
+
 ostream&
 operator<<(ostream& os, const AbstractRRset& rrset) {
     os << rrset.toText();
diff --git a/src/lib/dns/rrset.h b/src/lib/dns/rrset.h
index 5042a98..7ad555f 100644
--- a/src/lib/dns/rrset.h
+++ b/src/lib/dns/rrset.h
@@ -475,6 +475,14 @@ public:
     /// \brief Clear the RRSIGs for this RRset
     virtual void removeRRsig() = 0;
 
+    /// \brief Check whether two RRsets are of the same kind
+    ///
+    /// Checks if two RRsets have the same name, RR type, and RR class.
+    ///
+    /// \param other Pointer to another AbstractRRset to compare
+    ///              against.
+    virtual bool isSameKind(const AbstractRRset& other) const;
+
     //@}
 };
 
diff --git a/src/lib/dns/tests/rrset_unittest.cc b/src/lib/dns/tests/rrset_unittest.cc
index a6bfe56..a10b515 100644
--- a/src/lib/dns/tests/rrset_unittest.cc
+++ b/src/lib/dns/tests/rrset_unittest.cc
@@ -112,6 +112,20 @@ TEST_F(RRsetTest, setName) {
     EXPECT_EQ(test_nsname, rrset_a.getName());
 }
 
+TEST_F(RRsetTest, isSameKind) {
+    RRset rrset_w(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
+    RRset rrset_x(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
+    RRset rrset_y(test_name, RRClass::IN(), RRType::NS(), RRTTL(3600));
+    RRset rrset_z(test_name, RRClass::CH(), RRType::A(), RRTTL(3600));
+    RRset rrset_p(test_nsname, RRClass::IN(), RRType::A(), RRTTL(3600));
+
+    EXPECT_TRUE(rrset_w.isSameKind(rrset_w));
+    EXPECT_TRUE(rrset_w.isSameKind(rrset_x));
+    EXPECT_FALSE(rrset_w.isSameKind(rrset_y));
+    EXPECT_FALSE(rrset_w.isSameKind(rrset_z));
+    EXPECT_FALSE(rrset_w.isSameKind(rrset_p));
+}
+
 void
 addRdataTestCommon(const RRset& rrset) {
     EXPECT_EQ(2, rrset.getRdataCount());



More information about the bind10-changes mailing list