From 6b8dde8fd34dcea2d1b756ea4de74084209759e0 Mon Sep 17 00:00:00 2001 From: EncodedVenom <32179912+EncodedVenom@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:04:04 -0400 Subject: [PATCH] Fix EmptyQuery to properly return an empty iterator (#70) * Fix EmptyQuery to properly return an empty iterator * Remove actualNoOperation and enforce style guide --- src/init.luau | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/init.luau b/src/init.luau index 8356b9b..6b8606f 100644 --- a/src/init.luau +++ b/src/init.luau @@ -655,14 +655,14 @@ local function get(world: World, entityId: i53, a: i53, b: i53?, c: i53?, d: i53 end end --- the less creation the better -local function actualNoOperation() end -local function noop(_self: Query, ...): () -> () - return actualNoOperation :: any +local function noop() + return nil end local EmptyQuery = { - __iter = iterNoop, + __iter = function() + return noop + end, next = noop, replace = noop, without = function(self) @@ -670,6 +670,8 @@ local EmptyQuery = { end } +setmetatable(EmptyQuery, EmptyQuery) + export type Query = typeof(EmptyQuery) type CompatibleArchetype = { archetype: Archetype, indices: { number } }