From c744828b70a9180b3290a95ed17788e6b4d9a715 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Sun, 24 Dec 2023 06:42:55 +0100 Subject: [PATCH] Return static noopQuery --- lib/World.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/World.lua b/lib/World.lua index 163d603..3d1fd08 100644 --- a/lib/World.lua +++ b/lib/World.lua @@ -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) @@ -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)