diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-05-06 13:30:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-06 13:30:58 +0200 |
| commit | b5f40df95cf975feba9871346e67e0bc6799ed0e (patch) | |
| tree | 988e959512e214dc64cddf32a493026d9e9073c8 /compiler/rustc_data_structures/src | |
| parent | ae409558e7ec0a9944b879017fd827b57aa34522 (diff) | |
| parent | 4bd5505718696a1ec76e156b91561428468371bb (diff) | |
| download | rust-b5f40df95cf975feba9871346e67e0bc6799ed0e.tar.gz rust-b5f40df95cf975feba9871346e67e0bc6799ed0e.zip | |
Rollup merge of #84923 - estebank:as_cache_key-once, r=petrochenkov
Only compute Obligation `cache_key` once in `register_obligation_at`
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/obligation_forest/mod.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index a5b2df1da5d..29d685ab530 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -336,12 +336,13 @@ impl<O: ForestObligation> ObligationForest<O> { // Returns Err(()) if we already know this obligation failed. fn register_obligation_at(&mut self, obligation: O, parent: Option<usize>) -> Result<(), ()> { - if self.done_cache.contains(&obligation.as_cache_key()) { + let cache_key = obligation.as_cache_key(); + if self.done_cache.contains(&cache_key) { debug!("register_obligation_at: ignoring already done obligation: {:?}", obligation); return Ok(()); } - match self.active_cache.entry(obligation.as_cache_key()) { + match self.active_cache.entry(cache_key.clone()) { Entry::Occupied(o) => { let node = &mut self.nodes[*o.get()]; if let Some(parent_index) = parent { @@ -365,7 +366,7 @@ impl<O: ForestObligation> ObligationForest<O> { && self .error_cache .get(&obligation_tree_id) - .map(|errors| errors.contains(&obligation.as_cache_key())) + .map(|errors| errors.contains(&cache_key)) .unwrap_or(false); if already_failed { |
