3x faster typechecking

This commit is contained in:
Eric Holk 2012-07-25 18:00:29 -07:00
parent 3aee39a6ec
commit e1d4bd463c
3 changed files with 8 additions and 8 deletions

View File

@ -27,7 +27,7 @@ fn mk<T: copy>() -> smallintmap<T> {
*/
#[inline(always)]
fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) {
//#error("inserting key %?", key);
//io::println(#fmt("%?", key));
self.v.grow_set_elt(key, none, some(val));
}

View File

@ -109,7 +109,7 @@
in_scope_regions: isr_alist,
node_types: smallintmap::smallintmap<ty::t>,
node_types: hashmap<ast::node_id, ty::t>,
node_type_substs: hashmap<ast::node_id, ty::substs>,
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<ty::region, ~str> {
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(

View File

@ -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<ty::t> {
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