Skip to content

Commit 1fece3d

Browse files
committed
Optimize plug_leaks.
This commit avoids the `fold_regions` call in `plug_leaks` when `skol_map` is empty, which is the common case. This gives speed-ups of up to 1.14x on some of the rustc-benchmarks.
1 parent 8ccfc69 commit 1fece3d

File tree

1 file changed

+4
-3
lines changed
  • src/librustc/infer/higher_ranked

1 file changed

+4
-3
lines changed

src/librustc/infer/higher_ranked/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
756756
skol_map,
757757
value);
758758

759+
if skol_map.is_empty() {
760+
return self.resolve_type_vars_if_possible(value);
761+
}
762+
759763
// Compute a mapping from the "taint set" of each skolemized
760764
// region back to the `ty::BoundRegion` that it originally
761765
// represented. Because `leak_check` passed, we know that
@@ -813,9 +817,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
813817
}
814818
});
815819

816-
debug!("plug_leaks: result={:?}",
817-
result);
818-
819820
self.pop_skolemized(skol_map, snapshot);
820821

821822
debug!("plug_leaks: result={:?}", result);

0 commit comments

Comments
 (0)