diff options
| author | Patrick Walton <[email protected]> | 2011-04-22 10:37:51 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-22 10:37:51 -0700 |
| commit | 9edaa7dba3181ae68c60204e1e47a2d20e86236e (patch) | |
| tree | a56f52dbda71faa2833e6b198a128f2ac79c57e6 /src/comp | |
| parent | rustc: Improve the efficiency of lookup_item_type() slightly (diff) | |
| download | rust-9edaa7dba3181ae68c60204e1e47a2d20e86236e.tar.xz rust-9edaa7dba3181ae68c60204e1e47a2d20e86236e.zip | |
rustc: Add a fast path if there are no type substitutions to be made
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/ty.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 59de7768..96479c40 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -2362,9 +2362,15 @@ mod Unify { auto ures = unify_step(cx, expected, actual); alt (ures) { - case (ures_ok(?t)) { + case (ures_ok(?typ)) { + // Fast path: if there are no local variables, don't perform + // substitutions. + if (_vec.len[mutable UFind.node](cx.sets.nodes) == 0u) { + ret ures_ok(typ); + } + auto set_types = unify_sets(cx); - auto t2 = substitute(cx, set_types, t); + auto t2 = substitute(cx, set_types, typ); ret ures_ok(t2); } case (_) { ret ures; } |