librustc: De-@mut CrateContext::type_hashcodes

This commit is contained in:
Patrick Walton 2013-12-18 18:03:59 -08:00
parent a1747a6091
commit 25337a7f9f
2 changed files with 13 additions and 9 deletions

View File

@ -521,14 +521,18 @@ pub fn symbol_hash(tcx: ty::ctxt,
}
pub fn get_symbol_hash(ccx: &mut CrateContext, t: ty::t) -> @str {
match ccx.type_hashcodes.find(&t) {
Some(&h) => h,
None => {
let hash = symbol_hash(ccx.tcx, &mut ccx.symbol_hasher, t, &ccx.link_meta);
ccx.type_hashcodes.insert(t, hash);
hash
}
{
let type_hashcodes = ccx.type_hashcodes.borrow();
match type_hashcodes.get().find(&t) {
Some(&h) => return h,
None => {}
}
}
let mut type_hashcodes = ccx.type_hashcodes.borrow_mut();
let hash = symbol_hash(ccx.tcx, &mut ccx.symbol_hasher, t, &ccx.link_meta);
type_hashcodes.get().insert(t, hash);
hash
}

View File

@ -96,7 +96,7 @@ pub struct CrateContext {
llsizingtypes: RefCell<HashMap<ty::t, Type>>,
adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>,
symbol_hasher: Sha256,
type_hashcodes: HashMap<ty::t, @str>,
type_hashcodes: RefCell<HashMap<ty::t, @str>>,
type_short_names: HashMap<ty::t, ~str>,
all_llvm_symbols: HashSet<@str>,
tcx: ty::ctxt,
@ -207,7 +207,7 @@ pub fn new(sess: session::Session,
llsizingtypes: RefCell::new(HashMap::new()),
adt_reprs: RefCell::new(HashMap::new()),
symbol_hasher: symbol_hasher,
type_hashcodes: HashMap::new(),
type_hashcodes: RefCell::new(HashMap::new()),
type_short_names: HashMap::new(),
all_llvm_symbols: HashSet::new(),
tcx: tcx,