]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2539] Initialize SOA once during construction rather than in getSOA()
authorKean Johnston <kean@isc.org>
Sun, 26 Jan 2014 20:38:11 +0000 (22:38 +0200)
committerKean Johnston <kean@isc.org>
Sun, 26 Jan 2014 20:38:11 +0000 (22:38 +0200)
src/lib/datasrc/memory/memory_client.cc

index 3b573254831887f42ee7aa64b060e96b5edb8697..2acd0f19e04daf2da97ef34fa4ae2837e8de2764 100644 (file)
@@ -90,9 +90,9 @@ private:
     ZoneChain chain_;
     const RdataSet* set_node_;
     const RRClass rrclass_;
+    ConstRRsetPtr soa_;
     const ZoneTree& tree_;
     const ZoneNode* node_;
-    const ZoneNode* origin_node_;
     // Only used when separate_rrs_ is true
     ConstRRsetPtr rrset_;
     RdataIteratorPtr rdata_iterator_;
@@ -122,9 +122,22 @@ public:
                       "In-memory zone corrupted, missing origin node");
         }
 
-       // Save the origin node as node_ will be modified during
-       // iteration
-       origin_node_ = node_;
+        if (!node_) {
+            soa_ = ConstRRsetPtr();
+        } else {
+            const RdataSet* origin_set = node_->getData();
+            if (!origin_set) {
+                soa_ = ConstRRsetPtr();
+            } else {
+                const RdataSet* soa = RdataSet::find(origin_set, RRType::SOA());
+                if (!soa) {
+                    soa_ = ConstRRsetPtr();
+                } else {
+                    soa_ = ConstRRsetPtr (new TreeNodeRRset(rrclass_, node_,
+                                                            soa, true));
+                }
+            }
+        }
 
         // Initialize the iterator if there's somewhere to point to
         if (node_ != NULL && node_->getData() != NULL) {
@@ -237,23 +250,7 @@ public:
     }
 
     virtual ConstRRsetPtr getSOA() const {
-        // SOA will be at the origin node
-        if (!origin_node_) {
-            return (ConstRRsetPtr());
-        }
-
-        const RdataSet* origin_set = origin_node_->getData();
-        if (!origin_set) {
-            return (ConstRRsetPtr());
-        }
-
-        const RdataSet* soa = RdataSet::find(origin_set, RRType::SOA());
-        if (!soa) {
-            return (ConstRRsetPtr());
-        }
-
-        return (ConstRRsetPtr
-                (new TreeNodeRRset(rrclass_, origin_node_, soa, true)));
+        return (soa_);
     }
 };