about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-06-08 18:05:06 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-06-08 18:05:45 -0700
commitcc7a8b668f62d1e667d070759bfb7b57b284f0cb (patch)
tree03f21feebde330703d321b700591e116f393be7c
parent7527084e629340503fbe15b8e21c73879b5bd253 (diff)
rustc: Make resolve_all_vars() check to see whether the type actually has vars before folding over it; also remove some debug code. 2x typechecking speedup.
-rw-r--r--src/comp/middle/ty.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 0aa4a5c3821..021f8e32b6c 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -2099,38 +2099,31 @@ mod unify {
     // we eliminate pushdown. The typechecker should never rely on early
     // resolution of type variables.
     fn resolve_all_vars(&ty_ctxt tcx, &@var_bindings vb, t typ) -> t {
-        fn folder(ty_ctxt tcx, @var_bindings vb, @bool success, t typ) -> t {
+        if (!type_contains_vars(tcx, typ)) { ret typ; }
+
+        fn folder(ty_ctxt tcx, @var_bindings vb, t typ) -> t {
             alt (struct(tcx, typ)) {
                 case (ty_var(?vid)) {
                     // It's possible that we haven't even created the var set.
                     // Handle this case gracefully.
                     if ((vid as uint) >= ufind::set_count(vb.sets)) {
-                        *success = false; ret typ;
+                        ret typ;
                     }
 
                     auto root_id = ufind::find(vb.sets, vid as uint);
                     alt (smallintmap::find[t](vb.types, root_id)) {
                         case (some[t](?typ2)) {
-                            ret fold_ty(tcx, bind folder(tcx, vb, success, _),
-                                        typ2);
+                            ret fold_ty(tcx, bind folder(tcx, vb, _), typ2);
                         }
-                        case (none[t]) { *success = false; ret typ; }
+                        case (none[t]) { ret typ; }
                     }
-                    log ""; // fixes ambiguity
-                    *success = false; ret typ;
                 }
 
                 case (_) { ret typ; }
             }
         }
 
-        auto success = @true;
-        auto rty = fold_ty(tcx, bind folder(tcx, vb, success, _), typ);
-        /*if (*success) { ret rty; }
-        log_err "*** failed! type " + ty::ty_to_str(tcx, typ) + " => " +
-            ty::ty_to_str(tcx, rty);
-        ret typ;*/
-        ret rty;
+        ret fold_ty(tcx, bind folder(tcx, vb, _), typ);
     }
 
     fn unify_step(&@ctxt cx, &t expected, &t actual) -> result {