]> granicus.if.org Git - pdns/commitdiff
massively speed up DNSRecord operator<, also changing its semantics. We don't order...
authorbert hubert <bert.hubert@netherlabs.nl>
Sat, 24 Oct 2015 07:56:23 +0000 (09:56 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Sat, 24 Oct 2015 07:57:06 +0000 (09:57 +0200)
pdns/dnsparser.hh

index fa666495891943068c40940930d2ecbf45399ffe..936ca1005799ca458260de57bb99ec0467c1a440 100644 (file)
@@ -277,19 +277,19 @@ struct DNSRecord
 
   bool operator<(const DNSRecord& rhs) const
   {
+    if(tie(d_name, d_type, d_class) < tie(rhs.d_name, rhs.d_type, rhs.d_class))
+      return true;
+    
+    if(tie(d_name, d_type, d_class) != tie(rhs.d_name, rhs.d_type, rhs.d_class))
+      return false;
+    
     string lzrp, rzrp;
     if(d_content)
       lzrp=toLower(d_content->getZoneRepresentation());
     if(rhs.d_content)
       rzrp=toLower(rhs.d_content->getZoneRepresentation());
     
-    string llabel=toLower(d_name.toString());  
-    string rlabel=toLower(rhs.d_name.toString());
-
-    // XXX is anyone expecting a specific canonical ordering? can we use DNSName builtin < ?
-    return 
-      tie(llabel,     d_type,     d_class, lzrp) <
-      tie(rlabel, rhs.d_type, rhs.d_class, rzrp);
+    return lzrp < rzrp;
   }
 
   bool operator==(const DNSRecord& rhs) const