]> granicus.if.org Git - pdns/commitdiff
turns out we were using libc tolower in performance sensitive places.. top in perf
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 19 Feb 2016 20:28:05 +0000 (21:28 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 19 Feb 2016 20:28:05 +0000 (21:28 +0100)
pdns/dnsname.cc
pdns/dnsname.hh

index c2c9a710f25837ad0b7c83e5b8d9f8f455d7bb42..ddc3998c077cafc5d8e91380e03e49fed13374f9 100644 (file)
@@ -284,7 +284,7 @@ bool DNSName::operator==(const DNSName& rhs) const
   auto us = d_storage.crbegin();
   auto p = rhs.d_storage.crbegin();
   for(; us != d_storage.crend() && p != rhs.d_storage.crend(); ++us, ++p) {   // why does this go backward? 
-    if(tolower(*p) != tolower(*us))
+    if(dns2_tolower(*p) != dns2_tolower(*us))
       return false;
   }
   return true;
index 6e7e744ac863bf0c829890b9c8118388276fc31c..7c9326e08c21c786ee89c05afab4024235f10b33 100644 (file)
@@ -26,6 +26,12 @@ uint32_t burtleCI(const unsigned char* k, uint32_t lengh, uint32_t init);
    NOTE: For now, everything MUST be . terminated, otherwise it is an error
 */
 
+inline char dns2_tolower(char c)
+{
+  if(c>='A' && c<='Z')
+    c+='a'-'A';
+  return c;
+}
 
 class DNSName
 {
@@ -83,7 +89,7 @@ public:
     return std::lexicographical_compare(d_storage.rbegin(), d_storage.rend(), 
                                 rhs.d_storage.rbegin(), rhs.d_storage.rend(),
                                 [](const char& a, const char& b) {
-                                         return tolower(a) < tolower(b); 
+                                         return dns2_tolower(a) < dns2_tolower(b); 
                                        }); // note that this is case insensitive, including on the label lengths
   }
 
@@ -102,13 +108,6 @@ private:
 
 size_t hash_value(DNSName const& d);
 
-inline char dns2_tolower(char c)
-{
-  if(c>='A' && c<='Z')
-    c+='a'-'A';
-  return c;
-}
-
 
 inline bool DNSName::canonCompare(const DNSName& rhs) const
 {