librustc: De-@mut the short names cache
This commit is contained in:
parent
2612d76d22
commit
2e46ac6449
2 changed files with 18 additions and 8 deletions
|
|
@ -60,17 +60,27 @@ fn mywrite(w: @mut MemWriter, fmt: &fmt::Arguments) {
|
|||
pub fn enc_ty(w: @mut MemWriter, cx: @ctxt, t: ty::t) {
|
||||
match cx.abbrevs {
|
||||
ac_no_abbrevs => {
|
||||
let result_str = match cx.tcx.short_names_cache.find(&t) {
|
||||
Some(&s) => s,
|
||||
let result_str_opt;
|
||||
{
|
||||
let short_names_cache = cx.tcx.short_names_cache.borrow();
|
||||
result_str_opt = short_names_cache.get()
|
||||
.find(&t)
|
||||
.map(|result| *result);
|
||||
}
|
||||
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.inner_ref()).to_managed();
|
||||
cx.tcx.short_names_cache.insert(t, s);
|
||||
let mut short_names_cache = cx.tcx
|
||||
.short_names_cache
|
||||
.borrow_mut();
|
||||
short_names_cache.get().insert(t, s);
|
||||
s
|
||||
}
|
||||
};
|
||||
w.write(result_str.as_bytes());
|
||||
}
|
||||
};
|
||||
w.write(result_str.as_bytes());
|
||||
}
|
||||
ac_use_abbrevs(abbrevs) => {
|
||||
match abbrevs.find(&t) {
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ struct ctxt_ {
|
|||
freevars: freevars::freevar_map,
|
||||
tcache: type_cache,
|
||||
rcache: creader_cache,
|
||||
short_names_cache: @mut HashMap<t, @str>,
|
||||
short_names_cache: RefCell<HashMap<t, @str>>,
|
||||
needs_unwind_cleanup_cache: @mut HashMap<t, bool>,
|
||||
tc_cache: @mut HashMap<uint, TypeContents>,
|
||||
ast_ty_to_ty_cache: @mut HashMap<NodeId, ast_ty_to_ty_cache_entry>,
|
||||
|
|
@ -993,7 +993,7 @@ pub fn mk_ctxt(s: session::Session,
|
|||
freevars: freevars,
|
||||
tcache: @mut HashMap::new(),
|
||||
rcache: mk_rcache(),
|
||||
short_names_cache: new_ty_hash(),
|
||||
short_names_cache: RefCell::new(HashMap::new()),
|
||||
needs_unwind_cleanup_cache: new_ty_hash(),
|
||||
tc_cache: @mut HashMap::new(),
|
||||
ast_ty_to_ty_cache: @mut HashMap::new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue