diff options
| author | kennytm <kennytm@gmail.com> | 2018-07-17 02:18:15 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-07-17 19:24:47 +0800 |
| commit | 2d1880893fca2d24344519a08cc00535f6b52530 (patch) | |
| tree | bc20675a9c664bbb285faabaf4fe3330ddf68bec /src/librustc_data_structures | |
| parent | b086b09ef85620e1fd95c9d3aba4629174dd7809 (diff) | |
| parent | 384d04d31d35ef80324645d06e1afcf3ad48f4ed (diff) | |
| download | rust-2d1880893fca2d24344519a08cc00535f6b52530.tar.gz rust-2d1880893fca2d24344519a08cc00535f6b52530.zip | |
Rollup merge of #52306 - ljedrz:obligation_forest_clone, r=varkor
Reduce the number of clone()s needed in obligation_forest Some can be avoided by using `remove_entry` instead of `remove`.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/obligation_forest/mod.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index df34891ff03..0d6cf260dcd 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -496,9 +496,14 @@ impl<O: ForestObligation> ObligationForest<O> { } } NodeState::Done => { - self.waiting_cache.remove(self.nodes[i].obligation.as_predicate()); - // FIXME(HashMap): why can't I get my key back? - self.done_cache.insert(self.nodes[i].obligation.as_predicate().clone()); + // Avoid cloning the key (predicate) in case it exists in the waiting cache + if let Some((predicate, _)) = self.waiting_cache + .remove_entry(self.nodes[i].obligation.as_predicate()) + { + self.done_cache.insert(predicate); + } else { + self.done_cache.insert(self.nodes[i].obligation.as_predicate().clone()); + } node_rewrites[i] = nodes_len; dead_nodes += 1; } |
