Skip to content

Commit 5ef7e5c

Browse files
committed
Rename remaning to be more explicit
1 parent 1c0b66d commit 5ef7e5c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

crates/bevy_ecs/src/query/iter.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for QueryIter<'w, 's
5656
}
5757

5858
fn size_hint(&self) -> (usize, Option<usize>) {
59-
let max_size = self.cursor.remaining(self.tables, self.archetypes);
59+
let max_size = self.cursor.max_remaining(self.tables, self.archetypes);
6060
let archetype_query = Q::IS_ARCHETYPAL && F::IS_ARCHETYPAL;
6161
let min_size = if archetype_query { max_size } else { 0 };
6262
(min_size, Some(max_size))
@@ -425,7 +425,7 @@ impl<'w, 's, Q: ReadOnlyWorldQuery, F: ReadOnlyWorldQuery, const K: usize> Itera
425425
.iter()
426426
.enumerate()
427427
.try_fold(0, |acc, (i, cursor)| {
428-
let n = cursor.remaining(self.tables, self.archetypes);
428+
let n = cursor.max_remaining(self.tables, self.archetypes);
429429
Some(acc + choose(n, K - i)?)
430430
});
431431

@@ -556,8 +556,11 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryIterationCursor<'w, 's,
556556
}
557557
}
558558

559-
/// How many values will this cursor return?
560-
fn remaining(&self, tables: &'w Tables, archetypes: &'w Archetypes) -> usize {
559+
/// How many values will this cursor return at most?
560+
///
561+
/// Note that if `Q::IS_ARCHETYPAL && F::IS_ARCHETYPAL`, the return value
562+
/// will be **the exact count of remaining values**.
563+
fn max_remaining(&self, tables: &'w Tables, archetypes: &'w Archetypes) -> usize {
561564
let remaining_matched: usize = if Self::IS_DENSE {
562565
let ids = self.table_id_iter.clone();
563566
ids.map(|id| tables[*id].entity_count()).sum()

0 commit comments

Comments
 (0)