util.dns: Replace base16 implementation with util.hex
authorKim Alvefur <zash@zash.se>
Tue, 15 Feb 2022 13:03:02 +0100
changeset 12292 08a933450922
parent 12291 5cd075ed4fd3
child 12293 3a655adf1d0d
util.dns: Replace base16 implementation with util.hex Less code!
util/dns.lua
--- a/util/dns.lua	Mon Feb 14 18:29:31 2022 +0100
+++ b/util/dns.lua	Tue Feb 15 13:03:02 2022 +0100
@@ -9,7 +9,6 @@
 local t_concat = table.concat;
 local t_insert = table.insert;
 local s_byte = string.byte;
-local s_char = string.char;
 local s_format = string.format;
 local s_gsub = string.gsub;
 local s_sub = string.sub;
@@ -23,15 +22,7 @@
 	have_net = false;
 end
 
-local chartohex = {};
-
-for c = 0, 255 do
-	chartohex[s_char(c)] = s_format("%02X", c);
-end
-
-local function tohex(s)
-	return (s_gsub(s, ".", chartohex));
-end
+local tohex = require "util.hex".to;
 
 -- Simplified versions of Waqas DNS parsers
 -- Only the per RR parsers are needed and only feed a single RR