Remove upvalues

This commit is contained in:
Ukendio 2024-11-23 20:50:15 +01:00
parent 727cc93a7d
commit 46147cc9f9

View file

@ -330,51 +330,43 @@ local function hash(arr: { number }): string
return table.concat(arr, "_") return table.concat(arr, "_")
end end
local world_get: (world: World, entityId: i53, a: i53, b: i53?, c: i53?, d: i53?, e: i53?) -> ...any local function fetch(id, records: { ArchetypeRecord }, columns: { Column }, row: number): any
do local tr = records[id]
-- Keeping the function as small as possible to enable inlining
local records: { ArchetypeRecord }
local columns: { { any } }
local row: number
local function fetch(id): any if not tr then
local tr = records[id] return nil
if not tr then
return nil
end
return columns[tr.column][row]
end end
function world_get(world: World, entity: i53, a: i53, b: i53?, c: i53?, d: i53?, e: i53?): ...any return columns[tr.column][row]
local record = entity_index_try_get_fast(world.entity_index, entity) end
if not record then
return nil
end
local archetype = record.archetype local function world_get(world: World, entity: i53, a: i53, b: i53?, c: i53?, d: i53?, e: i53?): ...any
if not archetype then local record = entity_index_try_get_fast(world.entity_index, entity)
return nil if not record then
end return nil
end
records = archetype.records local archetype = record.archetype
columns = archetype.columns if not archetype then
row = record.row return nil
end
local va = fetch(a) local records = archetype.records
local columns = archetype.columns
local row = record.row
if not b then local va = fetch(a, records, columns, row)
return va
elseif not c then if not b then
return va, fetch(b) return va
elseif not d then elseif not c then
return va, fetch(b), fetch(c) return va, fetch(b, records, columns, row)
elseif not e then elseif not d then
return va, fetch(b), fetch(c), fetch(d) return va, fetch(b, records, columns, row), fetch(c, records, columns, row)
else elseif not e then
error("args exceeded") return va, fetch(b, records, columns, row), fetch(c, records, columns, row), fetch(d, records, columns, row)
end else
error("args exceeded")
end end
end end