Take advantage of inlining

This commit is contained in:
Someon1e 2024-03-03 21:08:25 +00:00
parent b4971cc76b
commit b7cfd3d405

View File

@ -20,7 +20,7 @@ local bit_replace = bit32.replace
local from_u32, from_u64, into_u64 local from_u32, from_u64, into_u64
local num_subtract, num_divide_unsigned, num_negate local num_subtract, num_divide_unsigned, num_negate
local num_or, num_shift_left, num_shift_right_unsigned local num_or, num_shift_left, num_shift_right_unsigned
local num_is_negative, num_is_zero, num_is_less_unsigned local num_is_less_unsigned
-- X: a[0 ..21] -- X: a[0 ..21]
-- Y: a[22..31] -- Y: a[22..31]
@ -36,6 +36,10 @@ function Numeric.from_u32(data_1, data_2)
return constructor(x, y, z) return constructor(x, y, z)
end end
local function num_is_zero(value)
return value == NUM_ZERO
end
local function load_d1(value) local function load_d1(value)
return bit_replace(bit_and(value.X, 0x3FFFFF), value.Z, 22, 10) return bit_replace(bit_and(value.X, 0x3FFFFF), value.Z, 22, 10)
end end
@ -180,6 +184,10 @@ function Numeric.divide_unsigned(lhs, rhs)
return quotient, remainder return quotient, remainder
end end
local function num_is_negative(value)
return value.Z >= 0x80000
end
function Numeric.divide_signed(lhs, rhs) function Numeric.divide_signed(lhs, rhs)
local left_negative = num_is_negative(lhs) local left_negative = num_is_negative(lhs)
local right_negative = num_is_negative(rhs) local right_negative = num_is_negative(rhs)
@ -336,14 +344,6 @@ function Numeric.rotate_right(lhs, rhs)
end end
end end
function Numeric.is_negative(value)
return value.Z >= 0x80000
end
function Numeric.is_zero(value)
return value == NUM_ZERO
end
function Numeric.is_equal(lhs, rhs) function Numeric.is_equal(lhs, rhs)
return lhs == rhs return lhs == rhs
end end
@ -400,8 +400,8 @@ num_or = Numeric.bit_or
num_shift_left = Numeric.shift_left num_shift_left = Numeric.shift_left
num_shift_right_unsigned = Numeric.shift_right_unsigned num_shift_right_unsigned = Numeric.shift_right_unsigned
num_is_negative = Numeric.is_negative Numeric.is_negative = num_is_negative
num_is_zero = Numeric.is_zero Numeric.is_zero = num_is_zero
num_is_less_unsigned = Numeric.is_less_unsigned num_is_less_unsigned = Numeric.is_less_unsigned
NUM_ONE = from_u64(1) NUM_ONE = from_u64(1)