Add small Luau optimizations
This commit is contained in:
parent
d3fc1fc891
commit
66818a8566
@ -1,13 +1,17 @@
|
|||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
|
local math_floor = math.floor
|
||||||
|
local math_ceil = math.ceil
|
||||||
|
|
||||||
local bit32 = bit32
|
local bit32 = bit32
|
||||||
|
local bit_band = bit32.band
|
||||||
|
|
||||||
local function no_op(x)
|
local function no_op(x)
|
||||||
return x
|
return x
|
||||||
end
|
end
|
||||||
|
|
||||||
local function to_u32(x)
|
local function to_u32(x)
|
||||||
return bit32.band(x, 0xFFFFFFFF)
|
return bit_band(x, 0xFFFFFFFF)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function to_i32(x)
|
local function to_i32(x)
|
||||||
@ -19,14 +23,14 @@ local function to_i32(x)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function wrap_i32(x)
|
local function wrap_i32(x)
|
||||||
return to_i32(to_u32(x) % 0x100000000)
|
return to_i32(to_u32(x))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function truncate(num)
|
local function truncate(num)
|
||||||
if num >= 0 then
|
if num >= 0 then
|
||||||
return math.floor(num)
|
return math_floor(num)
|
||||||
else
|
else
|
||||||
return math.ceil(num)
|
return math_ceil(num)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user