mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Fix EmptyQuery to properly return an empty iterator (#70)
* Fix EmptyQuery to properly return an empty iterator * Remove actualNoOperation and enforce style guide
This commit is contained in:
parent
706eded24f
commit
6b8dde8fd3
1 changed files with 7 additions and 5 deletions
|
@ -655,14 +655,14 @@ local function get(world: World, entityId: i53, a: i53, b: i53?, c: i53?, d: i53
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- the less creation the better
|
local function noop()
|
||||||
local function actualNoOperation() end
|
return nil
|
||||||
local function noop(_self: Query, ...): () -> ()
|
|
||||||
return actualNoOperation :: any
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local EmptyQuery = {
|
local EmptyQuery = {
|
||||||
__iter = iterNoop,
|
__iter = function()
|
||||||
|
return noop
|
||||||
|
end,
|
||||||
next = noop,
|
next = noop,
|
||||||
replace = noop,
|
replace = noop,
|
||||||
without = function(self)
|
without = function(self)
|
||||||
|
@ -670,6 +670,8 @@ local EmptyQuery = {
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setmetatable(EmptyQuery, EmptyQuery)
|
||||||
|
|
||||||
export type Query = typeof(EmptyQuery)
|
export type Query = typeof(EmptyQuery)
|
||||||
|
|
||||||
type CompatibleArchetype = { archetype: Archetype, indices: { number } }
|
type CompatibleArchetype = { archetype: Archetype, indices: { number } }
|
||||||
|
|
Loading…
Reference in a new issue