]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1603] proposed update to labelsequence: use internal loop, not strncasecmp.
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 7 Mar 2012 00:05:22 +0000 (16:05 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 7 Mar 2012 00:05:22 +0000 (16:05 -0800)
according to benchmark it can improve the renderer performance 17% more.

src/lib/dns/labelsequence.cc

index b082c3970e3961d9fb7c38efc2002163f3138e9e..f3c213358be9a3a3d44689f8a485c64d16dd4745 100644 (file)
@@ -53,9 +53,20 @@ LabelSequence::equals(const LabelSequence& other, bool case_sensitive) const {
     }
     if (case_sensitive) {
         return (strncmp(data, other_data, len) == 0);
-    } else {
-        return (strncasecmp(data, other_data, len) == 0);
     }
+
+    // As long as the data was originally validated as (part of) a name,
+    // label length must never be a capital ascii character, so we can
+    // simply compare them after converting to lower characters.
+    for (size_t i = 0; i < len; ++i) {
+        const unsigned char ch = data[i];
+        const unsigned char other_ch = other_data[i];
+        if (isc::dns::name::internal::maptolower[ch] !=
+            isc::dns::name::internal::maptolower[other_ch]) {
+            return (false);
+        }
+    }
+    return (true);
 }
 
 void