Browse Source

bug #1748: Change code to use a condition expression

Mukund Sivaraman 13 years ago
parent
commit
1007c99c02
2 changed files with 8 additions and 9 deletions
  1. 7 8
      src/lib/dns/rrset.cc
  2. 1 1
      src/lib/dns/rrset.h

+ 7 - 8
src/lib/dns/rrset.cc

@@ -114,14 +114,13 @@ AbstractRRset::toWire(AbstractMessageRenderer& renderer) const {
 }
 
 bool
-AbstractRRset::isSameKind(const AbstractRRset& other) {
-    if (getType() != other.getType())
-        return false;
-    if (getClass() != other.getClass())
-        return false;
-    if (getName() != other.getName())
-        return false;
-    return true;
+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&

+ 1 - 1
src/lib/dns/rrset.h

@@ -481,7 +481,7 @@ public:
     ///
     /// \param other Pointer to another AbstractRRset to compare
     ///              against.
-    virtual bool isSameKind(const AbstractRRset& other);
+    virtual bool isSameKind(const AbstractRRset& other) const;
 
     //@}
 };