Skip to content

Commit f22bb2e

Browse files
committed
Use retain for waiting_cache in apply_rewrites().
It's more concise, more idiomatic, and measurably faster.
1 parent 6e48053 commit f22bb2e

File tree

1 file changed

+4
-6
lines changed
  • src/librustc_data_structures/obligation_forest

1 file changed

+4
-6
lines changed

src/librustc_data_structures/obligation_forest/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -717,17 +717,15 @@ impl<O: ForestObligation> ObligationForest<O> {
717717

718718
// This updating of `self.waiting_cache` is necessary because the
719719
// removal of nodes within `compress` can fail. See above.
720-
let mut kill_list = vec![];
721-
for (predicate, index) in &mut self.waiting_cache {
720+
self.waiting_cache.retain(|_predicate, index| {
722721
let new_i = node_rewrites[index.index()];
723722
if new_i >= nodes_len {
724-
kill_list.push(predicate.clone());
723+
false
725724
} else {
726725
*index = NodeIndex::new(new_i);
726+
true
727727
}
728-
}
729-
730-
for predicate in kill_list { self.waiting_cache.remove(&predicate); }
728+
});
731729
}
732730
}
733731

0 commit comments

Comments
 (0)