Test of integer size in a loop is really necessary?
ReallyNiceGuy opened this issue · 1 comments
ReallyNiceGuy commented
Hi.
Not really an issue, just a question.
On luainteger_bitsize, you run a loop with a step of 1.
From what I understand, in Lua, an Integer can be only 32 or 64 bits. Why not use a step of 32?
Or even:
local function luainteger_bitsize()
if -1>>32 == 0 then
return 32
end
return 64
end
Cheers.
edubart commented
The lua integer can be one of the following C data types:
int
at least 16 bits (reference https://en.wikipedia.org/wiki/C_data_types)long
at least 32 bitslong long
at least 64 bits
Although I find very unlikely anyone runs Lua in a machine where int
is 16 bits or long long
is greater than 64 bits.
The algorithm used there is not very important, because it's not a hot code path as it's called only once on the module setup. But anyway I have made the function step in 16 bits at least.