diff --git a/benches/visual/query.bench.luau b/benches/visual/query.bench.luau index d579dce3..37df1564 100644 --- a/benches/visual/query.bench.luau +++ b/benches/visual/query.bench.luau @@ -57,7 +57,7 @@ local function flip() end local common = 0 -local N = 2^16-2 +local N = 500 local archetypes = {} local hm = 0 @@ -170,20 +170,19 @@ return { end, Functions = { - ECR = function() - local matched = 0 - for entityId, firstComponent in registry2:view(B1, B4) do - matched += 1 + Mirror = function() + for i = 1, 1000 do + for entityId, firstComponent in mcs:query(E1, E4) do + end end + end, Jecs = function() - local matched = 0 - for entityId, firstComponent in ecs:query(D1, D4) do - matched += 1 + for i = 1, 1000 do + for entityId, firstComponent in ecs:query(D1, D4) do + end end - - end, }, } diff --git a/src/init.luau b/src/init.luau index 6446e86c..f9a4c46e 100644 --- a/src/init.luau +++ b/src/init.luau @@ -921,6 +921,19 @@ do return query end + local it = { + __iter = world_query_iter, + next = world_query_next, + with = world_query_with, + without = world_query_without, + replace = world_query_replace, + archetypes = function() + return compatible_archetypes + end + } :: any + + setmetatable(it, it) + function world_query(world: World, ...: any): Query -- breaking? if (...) == nil then @@ -990,19 +1003,6 @@ do entities = archetype.entities i = #entities - local it = { - __iter = world_query_iter, - next = world_query_next, - with = world_query_with, - without = world_query_without, - replace = world_query_replace, - archetypes = function() - return compatible_archetypes - end - } :: any - - setmetatable(it, it) - return it end end