about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2019-09-16 12:43:48 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2019-09-16 12:43:48 +1000
commitf22bb2e72267890782897c208bbc9114d023dfc7 (patch)
treede894039c5015720daed5046c3ac00f9daf4111a /src/librustc_data_structures
parent6e48053d5d0d1c81d9a7e6548cead05c4bbac63d (diff)
downloadrust-f22bb2e72267890782897c208bbc9114d023dfc7.tar.gz
rust-f22bb2e72267890782897c208bbc9114d023dfc7.zip
Use `retain` for `waiting_cache` in `apply_rewrites()`.
It's more concise, more idiomatic, and measurably faster.
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/obligation_forest/mod.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs
index 0fa1f707d7b..5b95bb136e9 100644
--- a/src/librustc_data_structures/obligation_forest/mod.rs
+++ b/src/librustc_data_structures/obligation_forest/mod.rs
@@ -717,17 +717,15 @@ impl<O: ForestObligation> ObligationForest<O> {
 
         // This updating of `self.waiting_cache` is necessary because the
         // removal of nodes within `compress` can fail. See above.
-        let mut kill_list = vec![];
-        for (predicate, index) in &mut self.waiting_cache {
+        self.waiting_cache.retain(|_predicate, index| {
             let new_i = node_rewrites[index.index()];
             if new_i >= nodes_len {
-                kill_list.push(predicate.clone());
+                false
             } else {
                 *index = NodeIndex::new(new_i);
+                true
             }
-        }
-
-        for predicate in kill_list { self.waiting_cache.remove(&predicate); }
+        });
     }
 }