PNG reader: Use bit library if available

This commit is contained in:
Lars Mueller 2023-07-21 18:11:20 +02:00
parent 15ad69b0fe
commit e064873012

@ -17,6 +17,19 @@ local function bit_xor(a, b)
return res
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 = {}
for i = 0, 255 do
local c = i
@ -467,4 +480,4 @@ end
insert(rope, text)
end)
return concat(rope)
end
end