From e1d4bd463c29e4224f0ac41652d75ffac8080683 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 25 Jul 2012 18:00:29 -0700 Subject: [PATCH] 3x faster typechecking --- src/libstd/smallintmap.rs | 2 +- src/rustc/middle/typeck/check.rs | 12 ++++++------ src/rustc/middle/typeck/check/writeback.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 09f14f4f63e..02948f58fc4 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -27,7 +27,7 @@ fn mk() -> smallintmap { */ #[inline(always)] fn insert(self: smallintmap, key: uint, val: T) { - //#error("inserting key %?", key); + //io::println(#fmt("%?", key)); self.v.grow_set_elt(key, none, some(val)); } diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 599bfc18b13..0b78fd1a505 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -109,7 +109,7 @@ in_scope_regions: isr_alist, - node_types: smallintmap::smallintmap, + node_types: hashmap, node_type_substs: hashmap, ccx: @crate_ctxt}; @@ -132,7 +132,7 @@ fn blank_fn_ctxt(ccx: @crate_ctxt, rty: ty::t, mut region_lb: region_bnd, mut region_ub: region_bnd, in_scope_regions: @nil, - node_types: smallintmap::mk(), + node_types: map::int_hash(), node_type_substs: map::int_hash(), ccx: ccx}) } @@ -218,7 +218,7 @@ fn check_fn(ccx: @crate_ctxt, {infcx: infer::new_infer_ctxt(tcx), locals: int_hash(), purity: decl.purity, - node_types: smallintmap::mk(), + node_types: map::int_hash(), node_type_substs: map::int_hash()} } some(fcx) { @@ -490,7 +490,7 @@ fn block_region() -> result { fn write_ty(node_id: ast::node_id, ty: ty::t) { #debug["write_ty(%d, %s) in fcx %s", node_id, ty_to_str(self.tcx(), ty), self.tag()]; - self.node_types.insert(node_id as uint, ty); + self.node_types.insert(node_id, ty); } fn write_substs(node_id: ast::node_id, +substs: ty::substs) { if !ty::substs_is_noop(substs) { @@ -515,7 +515,7 @@ fn to_ty(ast_t: @ast::ty) -> ty::t { } fn expr_ty(ex: @ast::expr) -> ty::t { - alt self.node_types.find(ex.id as uint) { + alt self.node_types.find(ex.id) { some(t) { t } none { self.tcx().sess.bug(#fmt["no type for expr %d (%s) in fcx %s", @@ -524,7 +524,7 @@ fn expr_ty(ex: @ast::expr) -> ty::t { } } fn node_ty(id: ast::node_id) -> ty::t { - alt self.node_types.find(id as uint) { + alt self.node_types.find(id) { some(t) { t } none { self.tcx().sess.bug( diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index 720c85bf18e..f97ff61dbf4 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -59,7 +59,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) fn maybe_resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) -> option { - if wbcx.fcx.node_types.contains_key(id as uint) { + if wbcx.fcx.node_types.contains_key(id) { resolve_type_vars_for_node(wbcx, sp, id) } else { none