Improve inlining of ECS_PAIR

This commit is contained in:
Ukendio 2024-05-13 00:00:05 +02:00
parent 10f0b8f129
commit 748df7b13d

View file

@ -58,10 +58,11 @@ local ECS_GENERATION_MASK = bit32.lshift(1, 16)
local function addFlags(isPair: boolean) local function addFlags(isPair: boolean)
local typeFlags = 0x0 local typeFlags = 0x0
if isPair then if isPair then
typeFlags = bit32.bor(typeFlags, FLAGS_PAIR) -- HIGHEST bit in the ID. typeFlags = bit32.bor(typeFlags, FLAGS_PAIR) -- HIGHEST bit in the ID.
end end
if false then if false then
typeFlags = bit32.bor(typeFlags, 0x4) -- Set the second flag to true typeFlags = bit32.bor(typeFlags, 0x4) -- Set the second flag to true
end end
if false then if false then
@ -116,17 +117,21 @@ end
-- gets the low ID -- gets the low ID
local ECS_PAIR_SECOND = ECS_ID local ECS_PAIR_SECOND = ECS_ID
local function ECS_PAIR(source: number, target: number) local function ECS_PAIR(first: number, second: number)
local id local target = WILDCARD
if source == WILDCARD then local relation
id = newId(ECS_PAIR_SECOND(target), WILDCARD)
elseif target == WILDCARD then if first == WILDCARD then
id = newId(ECS_PAIR_SECOND(source), WILDCARD) relation = second
elseif second == WILDCARD then
relation = first
else else
id = newId(ECS_PAIR_SECOND(target), ECS_PAIR_SECOND(source)) relation = second
target = ECS_PAIR_SECOND(first)
end end
return id + addFlags(--[[isPair]] true) return newId(
ECS_PAIR_SECOND(relation), target) + addFlags(--[[isPair]] true)
end end
local function getAlive(entityIndex: EntityIndex, id: i53) local function getAlive(entityIndex: EntityIndex, id: i53)