提交 1c1c591c 编写于 作者: W Wesley Wiser

[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.
上级 31ee872d
......@@ -1725,10 +1725,9 @@ fn visit_scopes<T>(
Scope::MacroRules(binding.parent_macro_rules_scope)
}
MacroRulesScope::Invocation(invoc_id) => Scope::MacroRules(
self.output_macro_rules_scopes
.get(&invoc_id)
.cloned()
.unwrap_or(self.invocation_parent_scopes[&invoc_id].macro_rules),
self.output_macro_rules_scopes.get(&invoc_id).cloned().unwrap_or_else(
|| self.invocation_parent_scopes[&invoc_id].macro_rules,
),
),
MacroRulesScope::Empty => Scope::Module(module),
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册