summaryrefslogtreecommitdiff
path: root/ecs/src/query
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-04-04 17:47:53 +0200
committerHampusM <hampus@hampusmat.com>2025-04-04 17:47:53 +0200
commit523d13eec4778bb0d5e25416f09f2e5f7fc27ca7 (patch)
tree5b7f6d336c0a0ef171b058e5e28f655c92b9900a /ecs/src/query
parentad2877956935375d74d0a0255dcf207c1673801c (diff)
perf(ecs): always store query terms on stack
Diffstat (limited to 'ecs/src/query')
-rw-r--r--ecs/src/query/flexible.rs8
-rw-r--r--ecs/src/query/term.rs8
2 files changed, 10 insertions, 6 deletions
diff --git a/ecs/src/query/flexible.rs b/ecs/src/query/flexible.rs
index 652b96f..2f0b5e7 100644
--- a/ecs/src/query/flexible.rs
+++ b/ecs/src/query/flexible.rs
@@ -14,13 +14,13 @@ use crate::World;
/// Low-level entity query structure.
#[derive(Debug)]
-pub struct Query<'world, 'terms>
+pub struct Query<'world, const MAX_TERM_CNT: usize>
{
component_storage: ReadGuard<'world, ComponentStorage>,
- terms: Terms<'terms>,
+ terms: Terms<MAX_TERM_CNT>,
}
-impl<'world, 'terms> Query<'world, 'terms>
+impl<'world, const MAX_TERM_CNT: usize> Query<'world, MAX_TERM_CNT>
{
/// Iterates over the entities matching this query.
#[must_use]
@@ -42,7 +42,7 @@ impl<'world, 'terms> Query<'world, 'terms>
}
}
- pub(crate) fn new(world: &'world World, terms: Terms<'terms>) -> Self
+ pub(crate) fn new(world: &'world World, terms: Terms<MAX_TERM_CNT>) -> Self
{
Self {
component_storage: world
diff --git a/ecs/src/query/term.rs b/ecs/src/query/term.rs
index 7f24147..ce453f0 100644
--- a/ecs/src/query/term.rs
+++ b/ecs/src/query/term.rs
@@ -14,7 +14,9 @@ impl<ComponentT> TermWithoutField for With<ComponentT>
where
ComponentT: Component,
{
- fn apply_to_terms_builder(terms_builder: &mut TermsBuilder<'_>)
+ fn apply_to_terms_builder<const MAX_TERM_CNT: usize>(
+ terms_builder: &mut TermsBuilder<MAX_TERM_CNT>,
+ )
{
terms_builder.with::<ComponentT>();
}
@@ -31,7 +33,9 @@ impl<ComponentT> TermWithoutField for Without<ComponentT>
where
ComponentT: Component,
{
- fn apply_to_terms_builder(terms_builder: &mut TermsBuilder<'_>)
+ fn apply_to_terms_builder<const MAX_TERM_CNT: usize>(
+ terms_builder: &mut TermsBuilder<MAX_TERM_CNT>,
+ )
{
terms_builder.without::<ComponentT>();
}