Remove unneeded locals

This commit is contained in:
kikito 2015-04-06 17:39:17 +02:00
parent 858b23b28d
commit 907bbd1655

11
md5.lua
View File

@ -30,7 +30,6 @@ local md5 = {
-- bit lib implementions -- bit lib implementions
local floor, abs, max = math.floor, math.abs, math.max
local char, byte, format, rep, sub = local char, byte, format, rep, sub =
string.char, string.byte, string.format, string.rep, string.sub string.char, string.byte, string.format, string.rep, string.sub
local bit_or, bit_and, bit_not, bit_xor, bit_rshift, bit_lshift local bit_or, bit_and, bit_not, bit_xor, bit_rshift, bit_lshift
@ -80,7 +79,7 @@ else
function bit_not(n) function bit_not(n)
local tbl = to_bits(n) local tbl = to_bits(n)
local size = max(#tbl, 32) local size = math.max(#tbl, 32)
for i = 1, size do for i = 1, size do
if(tbl[i] == 1) then if(tbl[i] == 1) then
tbl[i] = 0 tbl[i] = 0
@ -95,7 +94,7 @@ else
to_bits = function (n) to_bits = function (n)
if(n < 0) then if(n < 0) then
-- negative -- negative
return to_bits(bit_not(abs(n)) + 1) return to_bits(bit_not(math.abs(n)) + 1)
end end
-- to bits table -- to bits table
local tbl = {} local tbl = {}
@ -169,10 +168,12 @@ else
local high_bit = 0 local high_bit = 0
if(n < 0) then if(n < 0) then
-- negative -- negative
n = bit_not(abs(n)) + 1 n = bit_not(math.abs(n)) + 1
high_bit = 2147483648 -- 0x80000000 high_bit = 2147483648 -- 0x80000000
end end
local floor = math.floor
for i=1, bits do for i=1, bits do
n = n/2 n = n/2
n = bit_or(floor(n), high_bit) n = bit_or(floor(n), high_bit)
@ -183,7 +184,7 @@ else
function bit_lshift(n, bits) function bit_lshift(n, bits)
if(n < 0) then if(n < 0) then
-- negative -- negative
n = bit_not(abs(n)) + 1 n = bit_not(math.abs(n)) + 1
end end
for i=1, bits do for i=1, bits do