Navigation Menu

Skip to content

Commit

Permalink
Use retain for waiting_cache in apply_rewrites().
Browse files Browse the repository at this point in the history
It's more concise, more idiomatic, and measurably faster.
  • Loading branch information
nnethercote committed Sep 16, 2019
1 parent 6e48053 commit f22bb2e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/librustc_data_structures/obligation_forest/mod.rs
Expand Up @@ -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); }
});
}
}

Expand Down

0 comments on commit f22bb2e

Please sign in to comment.