Make it static

This commit is contained in:
Ukendio 2024-07-28 12:33:38 +02:00
parent 48990ad910
commit 18ead3ed19
2 changed files with 22 additions and 23 deletions

View file

@ -57,7 +57,7 @@ local function flip()
end end
local common = 0 local common = 0
local N = 2^16-2 local N = 500
local archetypes = {} local archetypes = {}
local hm = 0 local hm = 0
@ -170,20 +170,19 @@ return {
end, end,
Functions = { Functions = {
ECR = function() Mirror = function()
local matched = 0 for i = 1, 1000 do
for entityId, firstComponent in registry2:view(B1, B4) do for entityId, firstComponent in mcs:query(E1, E4) do
matched += 1 end
end end
end, end,
Jecs = function() Jecs = function()
local matched = 0 for i = 1, 1000 do
for entityId, firstComponent in ecs:query(D1, D4) do for entityId, firstComponent in ecs:query(D1, D4) do
matched += 1 end
end end
end, end,
}, },
} }

View file

@ -921,6 +921,19 @@ do
return query return query
end 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 function world_query(world: World, ...: any): Query
-- breaking? -- breaking?
if (...) == nil then if (...) == nil then
@ -990,19 +1003,6 @@ do
entities = archetype.entities entities = archetype.entities
i = #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 return it
end end
end end