]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Don't copy labels into a deque when inserting in StatNode
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 14 Mar 2018 17:27:33 +0000 (18:27 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 14 Mar 2018 17:27:33 +0000 (18:27 +0100)
pdns/statnode.cc
pdns/statnode.hh

index 358e220368c065779ee8a271d6a1007b3cd8b734..7e8578d8b195602c395157d82602f1f616a3ece9 100644 (file)
@@ -57,15 +57,12 @@ void  StatNode::visit(visitor_t visitor, Stat &newstat, unsigned int depth) cons
 void StatNode::submit(const DNSName& domain, int rcode, const ComboAddress& remote)
 {
   //  cerr<<"FIRST submit called on '"<<domain<<"'"<<endl;
-  vector<string> tmp = domain.getRawLabels();
+  std::vector<string> tmp = domain.getRawLabels();
   if(tmp.empty())
     return;
 
-  deque<string> parts;
-  for(auto const i : tmp) {
-    parts.push_back(i);
-  }
-  children[parts.back()].submit(parts, "", rcode, remote, 1);
+  auto last = tmp.end() - 1;
+  children[*last].submit(last, tmp.begin(), "", rcode, remote, 1);
 }
 
 /* www.powerdns.com. -> 
@@ -75,24 +72,22 @@ void StatNode::submit(const DNSName& domain, int rcode, const ComboAddress& remo
    www.powerdns.com. 
 */
 
-void StatNode::submit(deque<string>& labels, const std::string& domain, int rcode, const ComboAddress& remote, unsigned int count)
+void StatNode::submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, const ComboAddress& remote, unsigned int count)
 {
-  if(labels.empty())
-    return;
   //  cerr<<"Submit called for domain='"<<domain<<"': ";
   //  for(const std::string& n :  labels) 
   //    cerr<<n<<".";
   //  cerr<<endl;
   if(name.empty()) {
 
-    name=labels.back();
+    name=*end;
     //    cerr<<"Set short name to '"<<name<<"'"<<endl;
   }
   else {
     //    cerr<<"Short name was already set to '"<<name<<"'"<<endl;
   }
 
-  if(labels.size()==1) {
+  if(end == begin) {
     if (fullname.empty()) {
       fullname=name+"."+domain;
       labelsCount = count;
@@ -115,8 +110,8 @@ void StatNode::submit(deque<string>& labels, const std::string& domain, int rcod
       labelsCount = count;
     }
     //    cerr<<"Not yet end, set our fullname to '"<<fullname<<"', recursing"<<endl;
-    labels.pop_back();
-    children[labels.back()].submit(labels, fullname, rcode, remote, count+1);
+    end--;
+    children[*end].submit(end, begin, fullname, rcode, remote, count+1);
   }
 }
 
index beea6c8d314b2280fa1b39d8dd0cc9019e1fede5..b541d8843be1fd973ce871f3c370bf583ad19eaf 100644 (file)
@@ -64,5 +64,5 @@ public:
   children_t children;
 
 private:
-  void submit(std::deque<std::string>& labels, const std::string& domain, int rcode, const ComboAddress& remote, unsigned int count);
+  void submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, const ComboAddress& remote, unsigned int count);
 };