@@ -56,7 +56,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for QueryIter<'w, 's
56
56
}
57
57
58
58
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 ) ;
60
60
let archetype_query = Q :: IS_ARCHETYPAL && F :: IS_ARCHETYPAL ;
61
61
let min_size = if archetype_query { max_size } else { 0 } ;
62
62
( min_size, Some ( max_size) )
@@ -425,7 +425,7 @@ impl<'w, 's, Q: ReadOnlyWorldQuery, F: ReadOnlyWorldQuery, const K: usize> Itera
425
425
. iter ( )
426
426
. enumerate ( )
427
427
. 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 ) ;
429
429
Some ( acc + choose ( n, K - i) ?)
430
430
} ) ;
431
431
@@ -556,8 +556,11 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryIterationCursor<'w, 's,
556
556
}
557
557
}
558
558
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 {
561
564
let remaining_matched: usize = if Self :: IS_DENSE {
562
565
let ids = self . table_id_iter . clone ( ) ;
563
566
ids. map ( |id| tables[ * id] . entity_count ( ) ) . sum ( )
0 commit comments