mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
lets go fast
This commit is contained in:
parent
bee330c9a5
commit
354f100dd1
1 changed files with 5 additions and 7 deletions
12
lib/init.lua
12
lib/init.lua
|
@ -598,6 +598,7 @@ end
|
||||||
|
|
||||||
function World.observer(world: World, ...)
|
function World.observer(world: World, ...)
|
||||||
local componentIds = {...}
|
local componentIds = {...}
|
||||||
|
local idsCount = #componentIds
|
||||||
local hooks = world.hooks
|
local hooks = world.hooks
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -633,19 +634,16 @@ function World.observer(world: World, ...)
|
||||||
matched = true
|
matched = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local queryOutput = {}
|
local queryOutput = table.create(idsCount)
|
||||||
local length = 0
|
|
||||||
|
|
||||||
local row = change.offset
|
local row = change.offset
|
||||||
local archetype = change.archetype
|
local archetype = change.archetype
|
||||||
local columns = archetype.columns
|
local columns = archetype.columns
|
||||||
local archetypeRecords = archetype.records
|
local archetypeRecords = archetype.records
|
||||||
for _, id in componentIds do
|
for index, id in componentIds do
|
||||||
length += 1
|
queryOutput[index] = columns[archetypeRecords[id]][row]
|
||||||
queryOutput[length] = columns[archetypeRecords[id]][row]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return archetype.entities[row], unpack(queryOutput, 1, length)
|
return archetype.entities[row], unpack(queryOutput, 1, idsCount)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue