Skip to content

remove some oldmap::Hashmap from librustc #5201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use core::ptr;
use core::run;
use core::str;
use core::vec;
use std::oldmap::HashMap;
use std::sha1::sha1;
use syntax::ast;
use syntax::ast_map::{path, path_mod, path_name};
Expand Down
1 change: 0 additions & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
use std::getopts::groups;
use std::getopts::{opt_present};
use std::getopts;
use std::oldmap::HashMap;
use std;
use syntax::ast;
use syntax::ast_map;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use metadata::filesearch::FileSearch;
use metadata::loader;

use core::either;
use core::hashmap::linear::LinearMap;
use core::option;
use core::vec;
use syntax::attr;
Expand All @@ -29,7 +30,6 @@ use syntax::parse::token::ident_interner;
use syntax::print::pprust;
use syntax::visit;
use syntax::{ast, ast_util};
use std::oldmap::HashMap;

// Traverses an AST, reading all the information about use'd crates and extern
// libraries necessary for later resolving, typechecking, linking, etc.
Expand Down Expand Up @@ -306,7 +306,7 @@ fn resolve_crate_deps(e: @mut Env, cdata: @~[u8]) -> cstore::cnum_map {
debug!("resolving deps of external crate");
// The map from crate numbers in the crate we're resolving to local crate
// numbers
let cnum_map = HashMap();
let cnum_map = @mut LinearMap::new();
for decoder::get_crate_deps(e.intr, cdata).each |dep| {
let extrn_cnum = dep.cnum;
let cname = dep.name;
Expand Down
1 change: 0 additions & 1 deletion src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use core::dvec::DVec;
use core::vec;
use reader = std::ebml::reader;
use std::ebml;
use std::oldmap::HashMap;
use syntax::ast;
use syntax::ast_map;
use syntax::codemap::dummy_sp;
Expand Down
28 changes: 14 additions & 14 deletions src/librustc/metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ use metadata::creader;
use metadata::cstore;
use metadata::decoder;

use core::hashmap::linear::LinearMap;
use core::option;
use core::str;
use core::vec;
use std::oldmap::HashMap;
use std::oldmap;
use std;
use syntax::{ast, attr};
use syntax::parse::token::ident_interner;
Expand All @@ -31,7 +30,7 @@ use syntax::parse::token::ident_interner;
// local crate numbers (as generated during this session). Each external
// crate may refer to types in other external crates, and each has their
// own crate numbers.
pub type cnum_map = oldmap::HashMap<ast::crate_num, ast::crate_num>;
pub type cnum_map = @mut LinearMap<ast::crate_num, ast::crate_num>;

pub struct crate_metadata {
name: @~str,
Expand All @@ -41,7 +40,7 @@ pub struct crate_metadata {
}

pub struct CStore {
priv metas: oldmap::HashMap<ast::crate_num, @crate_metadata>,
priv metas: @mut LinearMap<ast::crate_num, @crate_metadata>,
priv extern_mod_crate_map: extern_mod_crate_map,
priv used_crate_files: ~[Path],
priv used_libraries: ~[~str],
Expand All @@ -50,11 +49,11 @@ pub struct CStore {
}

// Map from node_id's of local extern mod statements to crate numbers
type extern_mod_crate_map = oldmap::HashMap<ast::node_id, ast::crate_num>;
type extern_mod_crate_map = @mut LinearMap<ast::node_id, ast::crate_num>;

pub fn mk_cstore(intr: @ident_interner) -> CStore {
let meta_cache = oldmap::HashMap();
let crate_map = oldmap::HashMap();
let meta_cache = @mut LinearMap::new();
let crate_map = @mut LinearMap::new();
return CStore {
metas: meta_cache,
extern_mod_crate_map: crate_map,
Expand All @@ -67,7 +66,7 @@ pub fn mk_cstore(intr: @ident_interner) -> CStore {

pub fn get_crate_data(cstore: @mut CStore, cnum: ast::crate_num)
-> @crate_metadata {
return cstore.metas.get(&cnum);
return *cstore.metas.get(&cnum);
}

pub fn get_crate_hash(cstore: @mut CStore, cnum: ast::crate_num) -> @~str {
Expand All @@ -94,8 +93,8 @@ pub fn have_crate_data(cstore: @mut CStore, cnum: ast::crate_num) -> bool {
pub fn iter_crate_data(cstore: @mut CStore,
i: fn(ast::crate_num, @crate_metadata)) {
let metas = cstore.metas;
for metas.each |&k, &v| {
i(k, v);
for metas.each |&(k, v)| {
i(*k, *v);
}
}

Expand Down Expand Up @@ -132,15 +131,16 @@ pub fn get_used_link_args(cstore: @mut CStore) -> ~[~str] {
pub fn add_extern_mod_stmt_cnum(cstore: @mut CStore,
emod_id: ast::node_id,
cnum: ast::crate_num) {
let extern_mod_crate_map = cstore.extern_mod_crate_map;
extern_mod_crate_map.insert(emod_id, cnum);
cstore.extern_mod_crate_map.insert(emod_id, cnum);
}

pub fn find_extern_mod_stmt_cnum(cstore: @mut CStore,
emod_id: ast::node_id)
-> Option<ast::crate_num> {
let extern_mod_crate_map = cstore.extern_mod_crate_map;
extern_mod_crate_map.find(&emod_id)
match cstore.extern_mod_crate_map.find(&emod_id) {
Some(&a) => Some(a),
None => None,
}
}

// returns hashes of crates directly used by this crate. Hashes are
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use core::str;
use core::vec;
use std::ebml::reader;
use std::ebml;
use std::oldmap::HashMap;
use std::oldmap;
use std::serialize::Decodable;
use syntax::ast_map;
Expand Down Expand Up @@ -1129,8 +1128,8 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
}

match cdata.cnum_map.find(&did.crate) {
option::Some(n) => ast::def_id { crate: n, node: did.node },
option::None => fail!(~"didn't find a crate in the cnum_map")
Some(&n) => ast::def_id { crate: n, node: did.node },
None => fail!(~"didn't find a crate in the cnum_map")
}
}

Expand Down
30 changes: 15 additions & 15 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use core::dvec;
use core::flate;
use core::float;
use core::hash::{Hash, HashUtil};
use core::hashmap::linear::LinearMap;
use core::int;
use core::io::WriterUtil;
use core::io;
Expand All @@ -36,7 +37,6 @@ use core::str;
use core::to_bytes::IterBytes;
use core::uint;
use core::vec;
use std::oldmap::HashMap;
use std::serialize::Encodable;
use std::{ebml, oldmap};
use std;
Expand All @@ -55,7 +55,7 @@ use syntax;
use writer = std::ebml::writer;

// used by astencode:
type abbrev_map = oldmap::HashMap<ty::t, tyencode::ty_abbrev>;
type abbrev_map = @mut LinearMap<ty::t, tyencode::ty_abbrev>;

pub type encode_inlined_item = @fn(ecx: @EncodeContext,
ebml_w: writer::Encoder,
Expand All @@ -65,10 +65,10 @@ pub type encode_inlined_item = @fn(ecx: @EncodeContext,
pub struct EncodeParams {
diag: span_handler,
tcx: ty::ctxt,
reachable: HashMap<ast::node_id, ()>,
reachable: @mut LinearMap<ast::node_id, ()>,
reexports2: middle::resolve::ExportMap2,
item_symbols: HashMap<ast::node_id, ~str>,
discrim_symbols: HashMap<ast::node_id, ~str>,
item_symbols: @mut LinearMap<ast::node_id, ~str>,
discrim_symbols: @mut LinearMap<ast::node_id, ~str>,
link_meta: LinkMeta,
cstore: @mut cstore::CStore,
encode_inlined_item: encode_inlined_item
Expand All @@ -91,10 +91,10 @@ pub struct EncodeContext {
diag: span_handler,
tcx: ty::ctxt,
stats: @mut Stats,
reachable: HashMap<ast::node_id, ()>,
reachable: @mut LinearMap<ast::node_id, ()>,
reexports2: middle::resolve::ExportMap2,
item_symbols: HashMap<ast::node_id, ~str>,
discrim_symbols: HashMap<ast::node_id, ~str>,
item_symbols: @mut LinearMap<ast::node_id, ~str>,
discrim_symbols: @mut LinearMap<ast::node_id, ~str>,
link_meta: LinkMeta,
cstore: @mut cstore::CStore,
encode_inlined_item: encode_inlined_item,
Expand Down Expand Up @@ -234,11 +234,11 @@ fn encode_type(ecx: @EncodeContext, ebml_w: writer::Encoder, typ: ty::t) {
fn encode_symbol(ecx: @EncodeContext, ebml_w: writer::Encoder, id: node_id) {
ebml_w.start_tag(tag_items_data_item_symbol);
let sym = match ecx.item_symbols.find(&id) {
Some(ref x) => (/*bad*/copy *x),
None => {
ecx.diag.handler().bug(
fmt!("encode_symbol: id not found %d", id));
}
Some(&ref x) => (/*bad*/copy *x),
None => {
ecx.diag.handler().bug(
fmt!("encode_symbol: id not found %d", id));
}
};
ebml_w.writer.write(str::to_bytes(sym));
ebml_w.end_tag();
Expand All @@ -247,7 +247,7 @@ fn encode_symbol(ecx: @EncodeContext, ebml_w: writer::Encoder, id: node_id) {
fn encode_discriminant(ecx: @EncodeContext, ebml_w: writer::Encoder,
id: node_id) {
ebml_w.start_tag(tag_items_data_item_symbol);
ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(&id)));
ebml_w.writer.write(str::to_bytes(*ecx.discrim_symbols.get(&id)));
ebml_w.end_tag();
}

Expand Down Expand Up @@ -1307,7 +1307,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
link_meta: /*bad*/copy parms.link_meta,
cstore: parms.cstore,
encode_inlined_item: parms.encode_inlined_item,
type_abbrevs: ty::new_ty_hash()
type_abbrevs: @mut LinearMap::new()
};

let ebml_w = writer::Encoder(wr as io::Writer);
Expand Down
1 change: 0 additions & 1 deletion src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use core::vec;
use syntax::ast;
use syntax::ast::*;
use syntax::codemap::{respan, dummy_sp};
use std::oldmap::HashMap;

// Compact string representation for ty::t values. API ty_str &
// parse_from_str. Extra parameters are for converting to/from def_ids in the
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use core::prelude::*;
use middle::ty::{Vid, param_ty};
use middle::ty;

use core::hashmap::linear::LinearMap;
use core::io::WriterUtil;
use core::io;
use core::uint;
use core::vec;
use std::oldmap::HashMap;
use syntax::ast::*;
use syntax::diagnostic::span_handler;
use syntax::print::pprust::*;
Expand All @@ -47,7 +47,7 @@ pub struct ty_abbrev {

pub enum abbrev_ctxt {
ac_no_abbrevs,
ac_use_abbrevs(HashMap<ty::t, ty_abbrev>),
ac_use_abbrevs(@mut LinearMap<ty::t, ty_abbrev>),
}

fn cx_uses_abbrevs(cx: @ctxt) -> bool {
Expand All @@ -74,7 +74,7 @@ pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
}
ac_use_abbrevs(abbrevs) => {
match abbrevs.find(&t) {
Some(a) => { w.write_str(*a.s); return; }
Some(&a) => { w.write_str(*a.s); return; }
None => {
let pos = w.tell();
match ty::type_def_id(t) {
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use std::ebml::reader::get_doc;
use std::ebml::reader;
use std::ebml::writer::Encoder;
use std::ebml;
use std::oldmap::HashMap;
use std::prettyprint;
use std::serialize;
use std::serialize::{Encodable, EncoderHelpers, DecoderHelpers};
Expand Down Expand Up @@ -890,7 +889,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
do ebml_w.tag(c::tag_table_freevars) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
do ebml_w.emit_from_vec(**fv) |fv_entry| {
do ebml_w.emit_from_vec(***fv) |fv_entry| {
encode_freevar_entry(ebml_w, *fv_entry)
}
}
Expand Down Expand Up @@ -930,7 +929,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
// }
//}

do option::iter(&maps.mutbl_map.find(&id)) |_m| {
do option::iter(&maps.mutbl_map.find(&id)) |&_m| {
do ebml_w.tag(c::tag_table_mutbl) {
ebml_w.id(id);
}
Expand Down Expand Up @@ -984,7 +983,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
do ebml_w.tag(c::tag_table_capture_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
do ebml_w.emit_from_vec(*cap_vars) |cap_var| {
do ebml_w.emit_from_vec(**cap_vars) |cap_var| {
cap_var.encode(&ebml_w);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ use util::ppaux::ty_to_str;

use core::cmp;
use core::dvec::DVec;
use core::hashmap::linear::LinearMap;
use core::uint;
use core::vec;
use std::oldmap::HashMap;
use syntax::ast::{m_const, m_imm, m_mutbl};
use syntax::ast;
use syntax::ast_util;
Expand All @@ -47,7 +47,7 @@ struct CheckLoanCtxt {
bccx: @BorrowckCtxt,
req_maps: ReqMaps,

reported: HashMap<ast::node_id, ()>,
reported: @mut LinearMap<ast::node_id, ()>,

declared_purity: @mut ast::purity,
fn_args: @mut @~[ast::node_id]
Expand All @@ -71,7 +71,7 @@ pub fn check_loans(bccx: @BorrowckCtxt,
let clcx = @mut CheckLoanCtxt {
bccx: bccx,
req_maps: req_maps,
reported: HashMap(),
reported: @mut LinearMap::new(),
declared_purity: @mut ast::impure_fn,
fn_args: @mut @~[]
};
Expand Down Expand Up @@ -130,7 +130,7 @@ pub impl CheckLoanCtxt {
loop {
match pure_map.find(&scope_id) {
None => (),
Some(ref e) => return Some(pc_cmt((*e)))
Some(&e) => return Some(pc_cmt((e)))
}

match region_map.find(&scope_id) {
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/middle/borrowck/gather_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ use util::common::indenter;
use util::ppaux::{expr_repr, region_to_str};

use core::dvec;
use core::hashmap::linear::LinearMap;
use core::hashmap::linear::LinearSet;
use core::vec;
use std::oldmap::HashMap;

use syntax::ast::{m_const, m_imm, m_mutbl};
use syntax::ast;
use syntax::codemap::span;
Expand Down Expand Up @@ -82,7 +83,10 @@ struct GatherLoanCtxt {
pub fn gather_loans(bccx: @BorrowckCtxt, crate: @ast::crate) -> ReqMaps {
let glcx = @mut GatherLoanCtxt {
bccx: bccx,
req_maps: ReqMaps { req_loan_map: HashMap(), pure_map: HashMap() },
req_maps: ReqMaps {
req_loan_map: @mut LinearMap::new(),
pure_map: @mut LinearMap::new()
},
item_ub: 0,
root_ub: 0,
ignore_adjustments: LinearSet::new()
Expand Down
Loading