]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Implemnent dns_tolower() and dns_toupper() by table and fold into dnsname.{cc,hh} 11655/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 31 May 2022 08:34:02 +0000 (10:34 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 31 May 2022 08:36:02 +0000 (10:36 +0200)
Before:
'BurtleHashCI' 0.10 seconds: 66975796.8 runs/s, 0.01 usec/run

After:
'BurtleHashCI' 0.10 seconds: 96758136.6 runs/s, 0.01 usec/run

.not-formatted
pdns/Makefile.am
pdns/ascii.hh [deleted file]
pdns/dnsdistdist/Makefile.am
pdns/dnsdistdist/ascii.hh [deleted symlink]
pdns/dnsname.cc
pdns/dnsname.hh
pdns/rcpgenerator.cc
pdns/recursordist/Makefile.am
pdns/recursordist/ascii.hh [deleted symlink]
pdns/zoneparser-tng.cc

index 11b45e55148a278e00e23c5955e1e769ba7a718f..22c9a461b422431f45af857231f50c10c5894ea6 100644 (file)
@@ -6,7 +6,6 @@
 ./pdns/anadns.hh
 ./pdns/arguments.cc
 ./pdns/arguments.hh
-./pdns/ascii.hh
 ./pdns/auth-caches.cc
 ./pdns/auth-carbon.cc
 ./pdns/auth-packetcache.cc
index 3cda451347ffe40b2ba589bbb89639d539daf7fb..06be63a282890046ac69cfbed07383659b07948a 100644 (file)
@@ -186,7 +186,6 @@ EXTRA_PROGRAMS = \
 
 pdns_server_SOURCES = \
        arguments.cc arguments.hh \
-       ascii.hh \
        auth-caches.cc auth-caches.hh \
        auth-carbon.cc \
        auth-packetcache.cc auth-packetcache.hh \
diff --git a/pdns/ascii.hh b/pdns/ascii.hh
deleted file mode 100644 (file)
index 09f42de..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of PowerDNS or dnsdist.
- * Copyright -- PowerDNS.COM B.V. and its contributors
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * In addition, for the avoidance of any doubt, permission is granted to
- * link this program with OpenSSL and to (re)distribute the binaries
- * produced as the result of such linking.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#pragma once
-
-inline bool dns_isspace(char c)
-{
-  return c==' ' || c=='\t' || c=='\r' || c=='\n';
-}
-
-inline unsigned char dns_toupper(unsigned char c)
-{
-  if(c>='a' && c<='z')
-    c+='A'-'a';
-  return c;
-}
-
-inline unsigned char dns_tolower(unsigned char c)
-{
-  if(c>='A' && c<='Z')
-    c+='a'-'A';
-  return c;
-}
index f7c9e4bafc68d88720d959150e0f88397b98063b..e6e04cc5965396cf8b11bcb968fe473d877512ab 100644 (file)
@@ -123,7 +123,6 @@ dnsdist-web.$(OBJEXT): htmlfiles.h
 dnsdist-lua-ffi.$(OBJEXT): dnsdist-lua-ffi-interface.inc
 
 dnsdist_SOURCES = \
-       ascii.hh \
        base64.hh \
        bpf-filter.cc bpf-filter.hh \
        cachecleaner.hh \
diff --git a/pdns/dnsdistdist/ascii.hh b/pdns/dnsdistdist/ascii.hh
deleted file mode 120000 (symlink)
index 6d5e3eb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../ascii.hh
\ No newline at end of file
index 834378586f82cb70a8e137518c721b4abad68c1e..31dfa67ef1a3b6c714880a54a7beee325346c22b 100644 (file)
@@ -491,3 +491,74 @@ bool DNSName::has8bitBytes() const
 
   return false;
 }
+
+// clang-format off
+const unsigned char dns_toupper_table[256] = {
+  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+  0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+  0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+  0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+  0x60, 'A',  'B',  'C',  'D',  'E',  'F',  'G',
+  'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
+  'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
+  'X',  'Y',  'Z',  0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+  0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+};
+
+const unsigned char dns_tolower_table[256] = {
+  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+  0x40, 'a',  'b',  'c',  'd',  'e',  'f',  'g',
+  'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',
+  'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
+  'x',  'y',  'z',  0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+  0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+  0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+  0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+  0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+  0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+  0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+  0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+  0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+};
index 6c49d0bd8d3ce297c64b4795d676db45930b5d20..566b3bf7ffae43997cb5ee0626420d818e4f2c4d 100644 (file)
 #include <boost/container/string.hpp>
 #endif
 
-#include "ascii.hh"
+inline bool dns_isspace(char c)
+{
+  return c == ' ' || c == '\t' || c == '\r' || c == '\n';
+}
+
+extern const unsigned char dns_toupper_table[256],  dns_tolower_table[256];
+
+inline unsigned char dns_toupper(unsigned char c)
+{
+  return dns_toupper_table[c];
+}
+
+inline unsigned char dns_tolower(unsigned char c)
+{
+  return dns_tolower_table[c];
+}
 
 uint32_t burtleCI(const unsigned char* k, uint32_t length, uint32_t init);
 
index 9204773d379a51de05a65ce16af24797bf73ca6d..3d3dd073ff2a19388badd49e17d33284eafc8e34 100644 (file)
@@ -23,7 +23,6 @@
 #include "config.h"
 #endif
 #include "rcpgenerator.hh"
-#include "ascii.hh"
 #include "dnsparser.hh"
 #include "misc.hh"
 #include "utility.hh"
index dcf4fb55639aace732a0f41010856c4b9ec0e0f8..743a17b991d7bed06eacda748920190c9a94402d 100644 (file)
@@ -101,7 +101,6 @@ endif
 pdns_recursor_SOURCES = \
        aggressive_nsec.cc aggressive_nsec.hh \
        arguments.cc \
-       ascii.hh \
        axfr-retriever.hh axfr-retriever.cc \
        base32.cc base32.hh \
        base64.cc base64.hh \
diff --git a/pdns/recursordist/ascii.hh b/pdns/recursordist/ascii.hh
deleted file mode 120000 (symlink)
index 6d5e3eb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../ascii.hh
\ No newline at end of file
index d9c1594763f7bb388ae12cc2261a0c39166a8d31..f3cdbcb5b95f96ebccb7c0e4232b46b36271765f 100644 (file)
@@ -22,7 +22,6 @@
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
-#include "ascii.hh"
 #include "dnsparser.hh"
 #include "sstuff.hh"
 #include "misc.hh"