util.hmac: Some optimisations
authorMatthew Wild <mwild1@gmail.com>
Sun, 05 Jul 2009 17:10:42 +0100
changeset 1482 9734231a569f
parent 1481 6401460891b2
child 1483 efd19cdda6ca
util.hmac: Some optimisations
util/hmac.lua
--- a/util/hmac.lua	Sun Jul 05 17:06:22 2009 +0100
+++ b/util/hmac.lua	Sun Jul 05 17:10:42 2009 +0100
@@ -1,15 +1,18 @@
 local hashes = require "util.hashes"
 local xor = require "bit".bxor
 
+local t_insert, t_concat = table.insert, table.concat;
+local s_char = string.char;
+
 module "hmac"
 
 local function arraystr(array)
     local t = {}
-    for i = 1,table.getn(array) do
-        table.insert(t, string.char(array[i]))
+    for i = 1,#array do
+        t_insert(t, s_char(array[i]))
     end
 
-    return table.concat(t)
+    return t_concat(t)
 end
 
 --[[