mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Remove upvalues
This commit is contained in:
parent
727cc93a7d
commit
46147cc9f9
1 changed files with 30 additions and 38 deletions
68
jecs.luau
68
jecs.luau
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue