net.stun: Use util.strbitop
authorKim Alvefur <zash@zash.se>
Fri, 04 Mar 2022 16:55:32 +0100
changeset 12363 f81488951f81
parent 12362 d77d8fba44ad
child 12364 0801db678f5e
net.stun: Use util.strbitop Improves performance since the whole procedure is done in C
net/stun.lua
--- a/net/stun.lua	Mon Jun 28 03:56:45 2021 +0200
+++ b/net/stun.lua	Fri Mar 04 16:55:32 2022 +0100
@@ -3,17 +3,7 @@
 local net = require "util.net";
 local random = require "util.random";
 local struct = require "util.struct";
-
---- Private helpers
-
--- XORs a string with another string
-local function sxor(x, y)
-	local r = {};
-	for i = 1, #x do
-		r[i] = string.char(bit32.bxor(x:byte(i), y:byte(i)));
-	end
-	return table.concat(r);
-end
+local sxor = require"util.strbitop".sxor;
 
 --- Public helpers