diff --git a/lib/init.lua b/lib/init.lua index 9036379..6b0dd51 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -408,10 +408,7 @@ function World.query(world: World, ...: i53): any function preparedQuery:without(...) local components = { ... } - for i, component in components do - components[i] = component - end - for i = #compatibleArchetypes, 1, - 1 do + for i = #compatibleArchetypes, 1, -1 do local archetype = compatibleArchetypes[i].archetype local shouldRemove = false for _, componentId in components do @@ -424,6 +421,12 @@ function World.query(world: World, ...: i53): any table.remove(compatibleArchetypes, i) end end + + lastArchetype, compatibleArchetype = next(compatibleArchetypes) + if not lastArchetype then + return noop() + end + return self end diff --git a/lib/init.spec.lua b/lib/init.spec.lua index a0e4aa7..0d12986 100644 --- a/lib/init.spec.lua +++ b/lib/init.spec.lua @@ -117,7 +117,23 @@ return function() added += 1 end expect(added).to.equal(hm) - print(added, hm) + end) + + it("should skip iteration", function() + local Position, Velocity = world:entity(), world:entity() + print(Position, Velocity) + local e = world:entity() + print(e) + world:set(e, Position, Vector3.zero) + world:set(e, Velocity, Vector3.one) + local added = 0 + for i in world:query(Position):without(Velocity) do + print(i) + added += 1 + end + expect(added).to.equal(0) + + end) it("track changes", function() diff --git a/test.project.json b/test.project.json index 28d10df..b931a84 100644 --- a/test.project.json +++ b/test.project.json @@ -23,9 +23,6 @@ "benches": { "$path": "benches" }, - "rewrite": { - "$path": "matterRewrite" - }, "mirror": { "$path": "mirror" }