librustc: De-@str
symbol hashing
This commit is contained in:
parent
1e0c07d011
commit
b265dd4156
@ -510,7 +510,8 @@ fn truncated_hash_result(symbol_hasher: &mut Sha256) -> ~str {
|
|||||||
pub fn symbol_hash(tcx: ty::ctxt,
|
pub fn symbol_hash(tcx: ty::ctxt,
|
||||||
symbol_hasher: &mut Sha256,
|
symbol_hasher: &mut Sha256,
|
||||||
t: ty::t,
|
t: ty::t,
|
||||||
link_meta: &LinkMeta) -> @str {
|
link_meta: &LinkMeta)
|
||||||
|
-> ~str {
|
||||||
// NB: do *not* use abbrevs here as we want the symbol names
|
// NB: do *not* use abbrevs here as we want the symbol names
|
||||||
// to be independent of one another in the crate.
|
// to be independent of one another in the crate.
|
||||||
|
|
||||||
@ -523,15 +524,14 @@ pub fn symbol_hash(tcx: ty::ctxt,
|
|||||||
let mut hash = truncated_hash_result(symbol_hasher);
|
let mut hash = truncated_hash_result(symbol_hasher);
|
||||||
// Prefix with 'h' so that it never blends into adjacent digits
|
// Prefix with 'h' so that it never blends into adjacent digits
|
||||||
hash.unshift_char('h');
|
hash.unshift_char('h');
|
||||||
// tjc: allocation is unfortunate; need to change std::hash
|
hash
|
||||||
hash.to_managed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> @str {
|
pub fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> ~str {
|
||||||
{
|
{
|
||||||
let type_hashcodes = ccx.type_hashcodes.borrow();
|
let type_hashcodes = ccx.type_hashcodes.borrow();
|
||||||
match type_hashcodes.get().find(&t) {
|
match type_hashcodes.get().find(&t) {
|
||||||
Some(&h) => return h,
|
Some(h) => return h.to_str(),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,7 +539,7 @@ pub fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> @str {
|
|||||||
let mut type_hashcodes = ccx.type_hashcodes.borrow_mut();
|
let mut type_hashcodes = ccx.type_hashcodes.borrow_mut();
|
||||||
let mut symbol_hasher = ccx.symbol_hasher.borrow_mut();
|
let mut symbol_hasher = ccx.symbol_hasher.borrow_mut();
|
||||||
let hash = symbol_hash(ccx.tcx, symbol_hasher.get(), t, &ccx.link_meta);
|
let hash = symbol_hash(ccx.tcx, symbol_hasher.get(), t, &ccx.link_meta);
|
||||||
type_hashcodes.get().insert(t, hash);
|
type_hashcodes.get().insert(t, hash.clone());
|
||||||
hash
|
hash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ pub struct CrateContext {
|
|||||||
llsizingtypes: RefCell<HashMap<ty::t, Type>>,
|
llsizingtypes: RefCell<HashMap<ty::t, Type>>,
|
||||||
adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>,
|
adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>,
|
||||||
symbol_hasher: RefCell<Sha256>,
|
symbol_hasher: RefCell<Sha256>,
|
||||||
type_hashcodes: RefCell<HashMap<ty::t, @str>>,
|
type_hashcodes: RefCell<HashMap<ty::t, ~str>>,
|
||||||
all_llvm_symbols: RefCell<HashSet<@str>>,
|
all_llvm_symbols: RefCell<HashSet<@str>>,
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
maps: astencode::Maps,
|
maps: astencode::Maps,
|
||||||
|
Loading…
Reference in New Issue
Block a user