Skip to content

Commit 5f402b8

Browse files
committed
Add a fast path for identical regions in lub_concrete_regions
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%.
1 parent 07600c9 commit 5f402b8

File tree

1 file changed

+7
-0
lines changed
  • src/librustc/infer/lexical_region_resolve

1 file changed

+7
-0
lines changed

src/librustc/infer/lexical_region_resolve/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> {
274274

275275
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
276276
let tcx = self.tcx();
277+
278+
// Equal scopes can show up quite often, if the fixed point
279+
// iteration converges slowly, skip them
280+
if a == b {
281+
return a;
282+
}
283+
277284
match (a, b) {
278285
(&ty::ReClosureBound(..), _)
279286
| (_, &ty::ReClosureBound(..))

0 commit comments

Comments
 (0)