mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
replace EmptyQuery with static reference
This commit is contained in:
parent
1b1ae947d9
commit
94fee8b33e
1 changed files with 5 additions and 4 deletions
|
@ -360,8 +360,9 @@ local EmptyQuery = {
|
||||||
without = noop
|
without = noop
|
||||||
}
|
}
|
||||||
EmptyQuery.__index = EmptyQuery
|
EmptyQuery.__index = EmptyQuery
|
||||||
|
setmetatable(EmptyQuery, EmptyQuery)
|
||||||
|
|
||||||
export type Query = typeof(setmetatable({}, EmptyQuery))
|
export type Query = typeof(EmptyQuery)
|
||||||
|
|
||||||
function World.query(world: World, ...: i53): Query
|
function World.query(world: World, ...: i53): Query
|
||||||
local compatibleArchetypes = {}
|
local compatibleArchetypes = {}
|
||||||
|
@ -379,7 +380,7 @@ function World.query(world: World, ...: i53): Query
|
||||||
for i, componentId in components do
|
for i, componentId in components do
|
||||||
local map = componentIndex[componentId]
|
local map = componentIndex[componentId]
|
||||||
if not map then
|
if not map then
|
||||||
return setmetatable({}, EmptyQuery)
|
return EmptyQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
if firstArchetypeMap == nil or map.size < firstArchetypeMap.size then
|
if firstArchetypeMap == nil or map.size < firstArchetypeMap.size then
|
||||||
|
@ -415,7 +416,7 @@ function World.query(world: World, ...: i53): Query
|
||||||
|
|
||||||
local lastArchetype, compatibleArchetype = next(compatibleArchetypes)
|
local lastArchetype, compatibleArchetype = next(compatibleArchetypes)
|
||||||
if not lastArchetype then
|
if not lastArchetype then
|
||||||
return setmetatable({}, EmptyQuery)
|
return EmptyQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
local preparedQuery = {}
|
local preparedQuery = {}
|
||||||
|
@ -439,7 +440,7 @@ function World.query(world: World, ...: i53): Query
|
||||||
|
|
||||||
lastArchetype, compatibleArchetype = next(compatibleArchetypes)
|
lastArchetype, compatibleArchetype = next(compatibleArchetypes)
|
||||||
if not lastArchetype then
|
if not lastArchetype then
|
||||||
return setmetatable({}, EmptyQuery)
|
return EmptyQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
Loading…
Reference in a new issue