mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 07:13:45 +01:00
PNG reader: Use bit
library if available
This commit is contained in:
parent
15ad69b0fe
commit
e064873012
@ -17,6 +17,19 @@ local function bit_xor(a, b)
|
|||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Try to use `bit` library (if available) for a massive speed boost
|
||||||
|
local bit = rawget(_G, "bit")
|
||||||
|
if bit then
|
||||||
|
local bxor = bit.bxor
|
||||||
|
function bit_xor(a, b)
|
||||||
|
local res = bxor(a, b)
|
||||||
|
if res < 0 then -- convert signed to unsigned
|
||||||
|
return res + 2^32
|
||||||
|
end
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local crc_table = {}
|
local crc_table = {}
|
||||||
for i = 0, 255 do
|
for i = 0, 255 do
|
||||||
local c = i
|
local c = i
|
||||||
|
Loading…
Reference in New Issue
Block a user