Skip to content

Commit

Permalink
Make it static
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Jul 28, 2024
1 parent 48990ad commit 18ead3e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
19 changes: 9 additions & 10 deletions benches/visual/query.bench.luau
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ local function flip()
end

local common = 0
local N = 2^16-2
local N = 500
local archetypes = {}

local hm = 0
Expand Down Expand Up @@ -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,
},
}
26 changes: 13 additions & 13 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 18ead3e

Please sign in to comment.