mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Auto merge of #57697 - dotdash:fast_lex_reg_resol_item_bodies, r=nagisa
Use a faster early exit during region expansion Turns out that the equality check for regions is rather expensive, and the current early exit check works in such a way, that the comparison is even done twice. As we only really care about the case of equal scopes, we can perform a faster, more specialized check and move it up one level, so we can eventually skip the additional full comparison as well.
This commit is contained in:
@@ -241,6 +241,14 @@ fn expand_node(
|
||||
|
||||
match *b_data {
|
||||
VarValue::Value(cur_region) => {
|
||||
// Identical scopes can show up quite often, if the fixed point
|
||||
// iteration converges slowly, skip them
|
||||
if let (ReScope(a_scope), ReScope(cur_scope)) = (a_region, cur_region) {
|
||||
if a_scope == cur_scope {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let mut lub = self.lub_concrete_regions(a_region, cur_region);
|
||||
if lub == cur_region {
|
||||
return false;
|
||||
@@ -280,12 +288,6 @@ fn expand_node(
|
||||
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
|
||||
let tcx = self.tcx();
|
||||
|
||||
// Equal scopes can show up quite often, if the fixed point
|
||||
// iteration converges slowly, skip them
|
||||
if a == b {
|
||||
return a;
|
||||
}
|
||||
|
||||
match (a, b) {
|
||||
(&ty::ReClosureBound(..), _)
|
||||
| (_, &ty::ReClosureBound(..))
|
||||
|
||||
Reference in New Issue
Block a user