Skip to content

Commit

Permalink
Add a fast path for identical regions in lub_concrete_regions
Browse files Browse the repository at this point in the history
In functions with lots of region constraint, if the fixed point
iteration converges only slowly, a lot of the var/var constraints will
have equal regions most of the time. Yet, we still perform the LUB
calculation and try to intern the result. Especially the latter incurs
quite some overhead.

This reduces the take taken by the item bodies checking pass for the
unicode_normalization crate by about 75%.
  • Loading branch information
dotdash committed Jan 10, 2019
1 parent 07600c9 commit 5f402b8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustc/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {

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(..))
Expand Down

0 comments on commit 5f402b8

Please sign in to comment.