Remove unnecessary checks in lua 5.1

This commit is contained in:
kikito 2015-04-06 17:22:48 +02:00
parent 6a83ce8c21
commit 0950963cd3

12
md5.lua

@ -54,12 +54,6 @@ if ok then
bit_rshift, bit_lshift = normalize(bit.rshift), normalize(bit.lshift) bit_rshift, bit_lshift = normalize(bit.rshift), normalize(bit.lshift)
else else
local function check_int(n)
-- checking not float
if(n - floor(n) > 0) then
error("trying to use bitwise operation on non-integer!")
end
end
local function tbl2number(tbl) local function tbl2number(tbl)
local n = #tbl local n = #tbl
@ -88,7 +82,6 @@ else
for i = #small + 1, #big do for i = #small + 1, #big do
small[i] = 0 small[i] = 0
end end
end end
local to_bits -- needs to be declared before bit_not local to_bits -- needs to be declared before bit_not
@ -108,7 +101,6 @@ else
-- defined as local above -- defined as local above
to_bits = function (n) to_bits = function (n)
check_int(n)
if(n < 0) then if(n < 0) then
-- negative -- negative
return to_bits(bit_not(abs(n)) + 1) return to_bits(bit_not(abs(n)) + 1)
@ -185,8 +177,6 @@ else
end end
function bit_rshift(n, bits) function bit_rshift(n, bits)
check_int(n)
local high_bit = 0 local high_bit = 0
if(n < 0) then if(n < 0) then
-- negative -- negative
@ -202,8 +192,6 @@ else
end end
function bit_lshift(n, bits) function bit_lshift(n, bits)
check_int(n)
if(n < 0) then if(n < 0) then
-- negative -- negative
n = bit_not(abs(n)) + 1 n = bit_not(abs(n)) + 1