mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-06 03:52:53 +00:00
Auto merge of #78508 - wesleywiser:optimize_visit_scopes, r=petrochenkov
[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot path This improves the performance of the `resolve_crate` function by 30% for a very large single file crate with auto-generated C bindings. cc `@rylev`
This commit is contained in:
commit
6bdae9edd0
@ -1725,10 +1725,9 @@ impl<'a> Resolver<'a> {
|
|||||||
Scope::MacroRules(binding.parent_macro_rules_scope)
|
Scope::MacroRules(binding.parent_macro_rules_scope)
|
||||||
}
|
}
|
||||||
MacroRulesScope::Invocation(invoc_id) => Scope::MacroRules(
|
MacroRulesScope::Invocation(invoc_id) => Scope::MacroRules(
|
||||||
self.output_macro_rules_scopes
|
self.output_macro_rules_scopes.get(&invoc_id).cloned().unwrap_or_else(
|
||||||
.get(&invoc_id)
|
|| self.invocation_parent_scopes[&invoc_id].macro_rules,
|
||||||
.cloned()
|
),
|
||||||
.unwrap_or(self.invocation_parent_scopes[&invoc_id].macro_rules),
|
|
||||||
),
|
),
|
||||||
MacroRulesScope::Empty => Scope::Module(module),
|
MacroRulesScope::Empty => Scope::Module(module),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user