Skip to content

Commit 08d870e

Browse files
committed
auto merge of #5095 : thestinger/rust/smallintmap, r=catamorphism
Closes #4738. The `std::smallintmap` module doesn't use an implicit @ box so I just added that explicitly for now to make porting simple.
2 parents 00d8db5 + 1afddff commit 08d870e

File tree

9 files changed

+27
-268
lines changed

9 files changed

+27
-268
lines changed

src/librustc/middle/astencode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
860860
}
861861
}
862862
}
863-
do option::iter(&(*tcx.node_types).find(id as uint)) |ty| {
863+
do option::iter(&tcx.node_types.find(&(id as uint))) |&ty| {
864864
do ebml_w.tag(c::tag_table_node_type) {
865865
ebml_w.id(id);
866866
do ebml_w.tag(c::tag_table_val) {
@@ -1135,7 +1135,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
11351135
let ty = val_dsr.read_ty(xcx);
11361136
debug!("inserting ty for node %?: %s",
11371137
id, ty_to_str(dcx.tcx, ty));
1138-
(*dcx.tcx.node_types).insert(id as uint, ty);
1138+
dcx.tcx.node_types.insert(id as uint, ty);
11391139
} else if tag == (c::tag_table_node_type_subst as uint) {
11401140
let tys = val_dsr.read_tys(xcx);
11411141
dcx.tcx.node_type_substs.insert(id, tys);

src/librustc/middle/lint.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ use core::uint;
3434
use core::vec;
3535
use std::oldmap::{Map, HashMap};
3636
use std::oldmap;
37-
use std::oldsmallintmap::{Map, SmallIntMap};
38-
use std::oldsmallintmap;
37+
use std::smallintmap::SmallIntMap;
3938
use syntax::ast_util::{path_to_ident};
4039
use syntax::attr;
4140
use syntax::codemap::span;
@@ -275,7 +274,7 @@ pub fn get_lint_dict() -> LintDict {
275274
}
276275

277276
// This is a highly not-optimal set of data structure decisions.
278-
type LintModes = SmallIntMap<level>;
277+
type LintModes = @mut SmallIntMap<level>;
279278
type LintModeMap = HashMap<ast::node_id, LintModes>;
280279

281280
// settings_map maps node ids of items with non-default lint settings
@@ -288,14 +287,14 @@ pub struct LintSettings {
288287

289288
pub fn mk_lint_settings() -> LintSettings {
290289
LintSettings {
291-
default_settings: oldsmallintmap::mk(),
290+
default_settings: @mut SmallIntMap::new(),
292291
settings_map: HashMap()
293292
}
294293
}
295294

296295
pub fn get_lint_level(modes: LintModes, lint: lint) -> level {
297-
match modes.find(lint as uint) {
298-
Some(c) => c,
296+
match modes.find(&(lint as uint)) {
297+
Some(&c) => c,
299298
None => allow
300299
}
301300
}
@@ -314,8 +313,7 @@ pub fn get_lint_settings_level(settings: LintSettings,
314313
// This is kind of unfortunate. It should be somewhere else, or we should use
315314
// a persistent data structure...
316315
fn clone_lint_modes(modes: LintModes) -> LintModes {
317-
oldsmallintmap::SmallIntMap_(@oldsmallintmap::SmallIntMap_
318-
{v: copy modes.v})
316+
@mut (copy *modes)
319317
}
320318

321319
struct Context {
@@ -332,7 +330,7 @@ impl Context {
332330

333331
fn set_level(&self, lint: lint, level: level) {
334332
if level == allow {
335-
self.curr.remove(lint as uint);
333+
self.curr.remove(&(lint as uint));
336334
} else {
337335
self.curr.insert(lint as uint, level);
338336
}
@@ -440,7 +438,7 @@ fn build_settings_item(i: @ast::item, &&cx: Context, v: visit::vt<Context>) {
440438
pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) {
441439
let cx = Context {
442440
dict: get_lint_dict(),
443-
curr: oldsmallintmap::mk(),
441+
curr: @mut SmallIntMap::new(),
444442
is_default: true,
445443
sess: sess
446444
};
@@ -458,7 +456,7 @@ pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) {
458456

459457
do cx.with_lint_attrs(/*bad*/copy crate.node.attrs) |cx| {
460458
// Copy out the default settings
461-
for cx.curr.each |k, v| {
459+
for cx.curr.each |&(k, &v)| {
462460
sess.lint_settings.default_settings.insert(k, v);
463461
}
464462

src/librustc/middle/trans/base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ use core::option::{is_none, is_some};
7676
use core::option;
7777
use core::uint;
7878
use std::oldmap::HashMap;
79-
use std::oldsmallintmap;
8079
use std::{oldmap, time, list};
8180
use syntax::ast_map::{path, path_elt_to_str, path_mod, path_name};
8281
use syntax::ast_util::{def_id_of_def, local_def, path_to_ident};

src/librustc/middle/ty.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ use core::uint;
4242
use core::vec;
4343
use core::hashmap::linear::LinearMap;
4444
use std::oldmap::HashMap;
45-
use std::{oldmap, oldsmallintmap};
45+
use std::oldmap;
46+
use std::smallintmap::SmallIntMap;
4647
use syntax::ast::*;
4748
use syntax::ast_util::{is_local, local_def};
4849
use syntax::ast_util;
@@ -767,7 +768,7 @@ type type_cache = HashMap<ast::def_id, ty_param_bounds_and_ty>;
767768

768769
type constness_cache = HashMap<ast::def_id, const_eval::constness>;
769770

770-
pub type node_type_table = @oldsmallintmap::SmallIntMap<t>;
771+
pub type node_type_table = @mut SmallIntMap<t>;
771772

772773
fn mk_rcache() -> creader_cache {
773774
type val = {cnum: int, pos: uint, len: uint};
@@ -812,7 +813,7 @@ pub fn mk_ctxt(s: session::Session,
812813
def_map: dm,
813814
region_map: region_map,
814815
region_paramd_items: region_paramd_items,
815-
node_types: @oldsmallintmap::mk(),
816+
node_types: @mut SmallIntMap::new(),
816817
node_type_substs: oldmap::HashMap(),
817818
items: amap,
818819
intrinsic_defs: oldmap::HashMap(),
@@ -2787,8 +2788,8 @@ pub fn br_hashmap<V:Copy>() -> HashMap<bound_region, V> {
27872788
27882789
pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
27892790
//io::println(fmt!("%?/%?", id, cx.node_types.len()));
2790-
match oldsmallintmap::find(*cx.node_types, id as uint) {
2791-
Some(t) => t,
2791+
match cx.node_types.find(&(id as uint)) {
2792+
Some(&t) => t,
27922793
None => cx.sess.bug(
27932794
fmt!("node_id_to_type: no type for node `%s`",
27942795
ast_map::node_id_to_str(cx.items, id,
@@ -3179,8 +3180,8 @@ pub fn expr_kind(tcx: ctxt,
31793180
}
31803181

31813182
ast::expr_cast(*) => {
3182-
match oldsmallintmap::find(*tcx.node_types, expr.id as uint) {
3183-
Some(t) => {
3183+
match tcx.node_types.find(&(expr.id as uint)) {
3184+
Some(&t) => {
31843185
if ty::type_is_immediate(t) {
31853186
RvalueDatumExpr
31863187
} else {

src/librustc/middle/typeck/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ use core::result;
277277
use core::vec;
278278
use std::list::Nil;
279279
use std::oldmap::HashMap;
280-
use std::oldsmallintmap;
280+
use std::smallintmap::SmallIntMap;
281281
use syntax::ast::{ret_style, purity};
282282
use syntax::ast::{m_const, m_imm, m_mutbl};
283283
use syntax::ast::{unsafe_fn, impure_fn, pure_fn, extern_fn};
@@ -353,7 +353,7 @@ pub fn fixup_err_to_str(f: fixup_err) -> ~str {
353353

354354
fn new_ValsAndBindings<V:Copy,T:Copy>() -> ValsAndBindings<V, T> {
355355
ValsAndBindings {
356-
vals: oldsmallintmap::mk(),
356+
vals: @mut SmallIntMap::new(),
357357
bindings: ~[]
358358
}
359359
}

src/librustc/middle/typeck/infer/unify.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use core::prelude::*;
1212
use core::result;
13-
use std::oldsmallintmap::SmallIntMap;
13+
use std::smallintmap::SmallIntMap;
1414

1515
use middle::ty::{Vid, expected_found, IntVarValue};
1616
use middle::ty;
@@ -27,7 +27,7 @@ pub enum VarValue<V, T> {
2727
}
2828

2929
pub struct ValsAndBindings<V, T> {
30-
vals: SmallIntMap<VarValue<V, T>>,
30+
vals: @mut SmallIntMap<VarValue<V, T>>,
3131
bindings: ~[(V, VarValue<V, T>)],
3232
}
3333

@@ -64,12 +64,12 @@ pub impl InferCtxt {
6464
vid: V) -> Node<V, T>
6565
{
6666
let vid_u = vid.to_uint();
67-
match vb.vals.find(vid_u) {
67+
match vb.vals.find(&vid_u) {
6868
None => {
6969
tcx.sess.bug(fmt!(
7070
"failed lookup of vid `%u`", vid_u));
7171
}
72-
Some(ref var_val) => {
72+
Some(var_val) => {
7373
match *var_val {
7474
Redirect(vid) => {
7575
let node: Node<V,T> = helper(tcx, vb, vid);
@@ -103,8 +103,8 @@ pub impl InferCtxt {
103103

104104
{ // FIXME(#4903)---borrow checker is not flow sensitive
105105
let vb = UnifyVid::appropriate_vals_and_bindings(self);
106-
let old_v = vb.vals.get(vid.to_uint());
107-
vb.bindings.push((vid, old_v));
106+
let old_v = vb.vals.get(&vid.to_uint());
107+
vb.bindings.push((vid, *old_v));
108108
vb.vals.insert(vid.to_uint(), new_v);
109109
}
110110
}

src/librustc/middle/typeck/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ use std::list::{List, Nil, Cons};
6969
use std::list;
7070
use std::oldmap::HashMap;
7171
use std::oldmap;
72-
use std::oldsmallintmap;
7372
use syntax::ast::{provided, required};
7473
use syntax::ast_map::node_id_to_str;
7574
use syntax::ast_util::{local_def, split_trait_methods};

0 commit comments

Comments
 (0)