@@ -177,29 +177,32 @@ impl<V> Memo<V> {
177
177
database_key_index : DatabaseKeyIndex ,
178
178
) -> bool {
179
179
let mut retry = false ;
180
- for head in self . cycle_heads ( ) {
181
- if head == database_key_index {
182
- continue ;
183
- }
184
- let ingredient = db. zalsa ( ) . lookup_ingredient ( head. ingredient_index ) ;
185
- if !ingredient. is_provisional_cycle_head ( db, head. key_index ) {
186
- // This cycle is already finalized, so we don't need to wait on it;
187
- // keep looping through cycle heads.
188
- retry = true ;
189
- continue ;
190
- }
191
- if ingredient. wait_for ( db, head. key_index ) {
192
- // There's a new memo available for the cycle head; fetch our own
193
- // updated memo and see if it's still provisional or if the cycle
194
- // has resolved.
195
- retry = true ;
196
- continue ;
197
- } else {
198
- // We hit a cycle blocking on the cycle head; this means it's in
199
- // our own active query stack and we are responsible to resolve the
200
- // cycle, so go ahead and return the provisional memo.
201
- return false ;
202
- }
180
+ let hit_cycle = self
181
+ . cycle_heads ( )
182
+ . into_iter ( )
183
+ . filter ( |& head| head != database_key_index)
184
+ . any ( |head| {
185
+ let ingredient = db. zalsa ( ) . lookup_ingredient ( head. ingredient_index ) ;
186
+ if !ingredient. is_provisional_cycle_head ( db, head. key_index ) {
187
+ // This cycle is already finalized, so we don't need to wait on it;
188
+ // keep looping through cycle heads.
189
+ retry = true ;
190
+ false
191
+ } else if ingredient. wait_for ( db, head. key_index ) {
192
+ // There's a new memo available for the cycle head; fetch our own
193
+ // updated memo and see if it's still provisional or if the cycle
194
+ // has resolved.
195
+ retry = true ;
196
+ false
197
+ } else {
198
+ // We hit a cycle blocking on the cycle head; this means it's in
199
+ // our own active query stack and we are responsible to resolve the
200
+ // cycle, so go ahead and return the provisional memo.
201
+ true
202
+ }
203
+ } ) ;
204
+ if hit_cycle {
205
+ return false ;
203
206
}
204
207
// If `retry` is `true`, all our cycle heads (barring ourself) are complete; re-fetch
205
208
// and we should get a non-provisional memo. If we get here and `retry` is still
0 commit comments