1
Fork 0

librustc: De-@str type short names

This commit is contained in:
Patrick Walton 2014-01-31 12:36:00 -08:00 committed by Huon Wilson
parent e9ce855beb
commit 0f3a4e13f9
2 changed files with 9 additions and 7 deletions

View file

@ -45,7 +45,7 @@ pub struct ctxt {
pub struct ty_abbrev {
pos: uint,
len: uint,
s: @str
s: ~str
}
pub enum abbrev_ctxt {
@ -65,19 +65,21 @@ pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) {
let short_names_cache = cx.tcx.short_names_cache.borrow();
result_str_opt = short_names_cache.get()
.find(&t)
.map(|result| *result);
.map(|result| {
(*result).clone()
});
}
let result_str = match result_str_opt {
Some(s) => s,
None => {
let wr = &mut MemWriter::new();
enc_sty(wr, cx, &ty::get(t).sty);
let s = str::from_utf8(wr.get_ref()).unwrap().to_managed();
let s = str::from_utf8(wr.get_ref()).unwrap();
let mut short_names_cache = cx.tcx
.short_names_cache
.borrow_mut();
short_names_cache.get().insert(t, s);
s
short_names_cache.get().insert(t, s.to_str());
s.to_str()
}
};
w.write(result_str.as_bytes());
@ -103,7 +105,7 @@ pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) {
let abbrev_len = 3 + estimate_sz(pos) + estimate_sz(len);
if abbrev_len < len {
// I.e. it's actually an abbreviation.
let s = format!("\\#{:x}:{:x}\\#", pos, len).to_managed();
let s = format!("\\#{:x}:{:x}\\#", pos, len);
let a = ty_abbrev { pos: pos as uint,
len: len as uint,
s: s };

View file

@ -291,7 +291,7 @@ pub struct ctxt_ {
freevars: RefCell<freevars::freevar_map>,
tcache: type_cache,
rcache: creader_cache,
short_names_cache: RefCell<HashMap<t, @str>>,
short_names_cache: RefCell<HashMap<t, ~str>>,
needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>,
tc_cache: RefCell<HashMap<uint, TypeContents>>,
ast_ty_to_ty_cache: RefCell<HashMap<NodeId, ast_ty_to_ty_cache_entry>>,