Skip to content

Commit 9edaa7d

Browse files
committed
rustc: Add a fast path if there are no type substitutions to be made
1 parent 9ab9bd9 commit 9edaa7d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/comp/middle/ty.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,9 +2362,15 @@ mod Unify {
23622362

23632363
auto ures = unify_step(cx, expected, actual);
23642364
alt (ures) {
2365-
case (ures_ok(?t)) {
2365+
case (ures_ok(?typ)) {
2366+
// Fast path: if there are no local variables, don't perform
2367+
// substitutions.
2368+
if (_vec.len[mutable UFind.node](cx.sets.nodes) == 0u) {
2369+
ret ures_ok(typ);
2370+
}
2371+
23662372
auto set_types = unify_sets(cx);
2367-
auto t2 = substitute(cx, set_types, t);
2373+
auto t2 = substitute(cx, set_types, typ);
23682374
ret ures_ok(t2);
23692375
}
23702376
case (_) { ret ures; }

0 commit comments

Comments
 (0)