Skip to content

Commit 94f29e0

Browse files
eholkpaulstansifer
authored andcommitted
3x faster typechecking
1 parent 0a8b794 commit 94f29e0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/libstd/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn mk<T: copy>() -> smallintmap<T> {
2727
*/
2828
#[inline(always)]
2929
fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) {
30-
//#error("inserting key %?", key);
30+
//io::println(#fmt("%?", key));
3131
self.v.grow_set_elt(key, none, some(val));
3232
}
3333

src/rustc/middle/typeck/check.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type fn_ctxt_ =
109109

110110
in_scope_regions: isr_alist,
111111

112-
node_types: smallintmap::smallintmap<ty::t>,
112+
node_types: hashmap<ast::node_id, ty::t>,
113113
node_type_substs: hashmap<ast::node_id, ty::substs>,
114114

115115
ccx: @crate_ctxt};
@@ -132,7 +132,7 @@ fn blank_fn_ctxt(ccx: @crate_ctxt, rty: ty::t,
132132
mut region_lb: region_bnd,
133133
mut region_ub: region_bnd,
134134
in_scope_regions: @nil,
135-
node_types: smallintmap::mk(),
135+
node_types: map::int_hash(),
136136
node_type_substs: map::int_hash(),
137137
ccx: ccx})
138138
}
@@ -218,7 +218,7 @@ fn check_fn(ccx: @crate_ctxt,
218218
{infcx: infer::new_infer_ctxt(tcx),
219219
locals: int_hash(),
220220
purity: decl.purity,
221-
node_types: smallintmap::mk(),
221+
node_types: map::int_hash(),
222222
node_type_substs: map::int_hash()}
223223
}
224224
some(fcx) {
@@ -490,7 +490,7 @@ impl methods for @fn_ctxt {
490490
fn write_ty(node_id: ast::node_id, ty: ty::t) {
491491
#debug["write_ty(%d, %s) in fcx %s",
492492
node_id, ty_to_str(self.tcx(), ty), self.tag()];
493-
self.node_types.insert(node_id as uint, ty);
493+
self.node_types.insert(node_id, ty);
494494
}
495495
fn write_substs(node_id: ast::node_id, +substs: ty::substs) {
496496
if !ty::substs_is_noop(substs) {
@@ -515,7 +515,7 @@ impl methods for @fn_ctxt {
515515
}
516516

517517
fn expr_ty(ex: @ast::expr) -> ty::t {
518-
alt self.node_types.find(ex.id as uint) {
518+
alt self.node_types.find(ex.id) {
519519
some(t) { t }
520520
none {
521521
self.tcx().sess.bug(#fmt["no type for expr %d (%s) in fcx %s",
@@ -524,7 +524,7 @@ impl methods for @fn_ctxt {
524524
}
525525
}
526526
fn node_ty(id: ast::node_id) -> ty::t {
527-
alt self.node_types.find(id as uint) {
527+
alt self.node_types.find(id) {
528528
some(t) { t }
529529
none {
530530
self.tcx().sess.bug(

src/rustc/middle/typeck/check/writeback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id)
5959
fn maybe_resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span,
6060
id: ast::node_id)
6161
-> option<ty::t> {
62-
if wbcx.fcx.node_types.contains_key(id as uint) {
62+
if wbcx.fcx.node_types.contains_key(id) {
6363
resolve_type_vars_for_node(wbcx, sp, id)
6464
} else {
6565
none

0 commit comments

Comments
 (0)