Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cached queries #166

Merged
merged 18 commits into from
Dec 26, 2024
Prev Previous commit
Next Next commit
Fix metatable
Ukendio committed Dec 26, 2024
commit 76aef4f1b1b257f49732638b5b3b473b2e15efed
13 changes: 6 additions & 7 deletions jecs.luau
Original file line number Diff line number Diff line change
@@ -1843,13 +1843,12 @@ local function query_cached(query: QueryInner)
return world_query_iter_next
end

return setmetatable(query, {
__index = {
archetypes = query_archetypes,
__iter = cached_query_iter,
iter = cached_query_iter
}
})
local cached_query = query :: any
cached_query.archetypes = query_archetypes
cached_query.__iter = cached_query_iter
cached_query.iter = cached_query_iter
setmetatable(cached_query, cached_query)
return cached_query
end

local Query = {}