Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Return static noopQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Dec 24, 2023
1 parent 4e9a28b commit c744828
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/World.lua
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ end

local function noop() end

local noopQuery = setmetatable({
next = noop,
snapshot = noop,
without = noop,
view = noop,
}, {
__iter = noop,
})

function World:query(...)
debug.profilebegin("World:query")
assertValidComponent((...), 1)
Expand All @@ -423,9 +432,7 @@ function World:query(...)

if next(compatibleArchetypes) == nil then
-- If there are no compatible storages avoid creating our complicated iterator
local noopQuery = setmetatable({}, QueryResult)
noopQuery._expand = noop
noopQuery._next = noop
return noopQuery
end

local queryOutput = table.create(queryLength)
Expand Down

0 comments on commit c744828

Please sign in to comment.