Skip to content

Commit 6a0450c

Browse files
committed
librustc: De-@mut the tc_cache
1 parent ba2e6c1 commit 6a0450c

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/librustc/middle/ty.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ struct ctxt_ {
309309
rcache: creader_cache,
310310
short_names_cache: RefCell<HashMap<t, @str>>,
311311
needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>,
312-
tc_cache: @mut HashMap<uint, TypeContents>,
312+
tc_cache: RefCell<HashMap<uint, TypeContents>>,
313313
ast_ty_to_ty_cache: @mut HashMap<NodeId, ast_ty_to_ty_cache_entry>,
314314
enum_var_cache: @mut HashMap<DefId, @~[@VariantInfo]>,
315315
ty_param_defs: @mut HashMap<ast::NodeId, TypeParameterDef>,
@@ -995,7 +995,7 @@ pub fn mk_ctxt(s: session::Session,
995995
rcache: mk_rcache(),
996996
short_names_cache: RefCell::new(HashMap::new()),
997997
needs_unwind_cleanup_cache: RefCell::new(HashMap::new()),
998-
tc_cache: @mut HashMap::new(),
998+
tc_cache: RefCell::new(HashMap::new()),
999999
ast_ty_to_ty_cache: @mut HashMap::new(),
10001000
enum_var_cache: @mut HashMap::new(),
10011001
methods: RefCell::new(HashMap::new()),
@@ -1970,14 +1970,20 @@ pub fn type_is_freezable(cx: ctxt, t: ty::t) -> bool {
19701970

19711971
pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
19721972
let ty_id = type_id(ty);
1973-
match cx.tc_cache.find(&ty_id) {
1974-
Some(tc) => { return *tc; }
1975-
None => {}
1973+
1974+
{
1975+
let tc_cache = cx.tc_cache.borrow();
1976+
match tc_cache.get().find(&ty_id) {
1977+
Some(tc) => { return *tc; }
1978+
None => {}
1979+
}
19761980
}
19771981

19781982
let mut cache = HashMap::new();
19791983
let result = tc_ty(cx, ty, &mut cache);
1980-
cx.tc_cache.insert(ty_id, result);
1984+
1985+
let mut tc_cache = cx.tc_cache.borrow_mut();
1986+
tc_cache.get().insert(ty_id, result);
19811987
return result;
19821988

19831989
fn tc_ty(cx: ctxt,
@@ -2010,9 +2016,12 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20102016
Some(tc) => { return *tc; }
20112017
None => {}
20122018
}
2013-
match cx.tc_cache.find(&ty_id) { // Must check both caches!
2014-
Some(tc) => { return *tc; }
2015-
None => {}
2019+
{
2020+
let tc_cache = cx.tc_cache.borrow();
2021+
match tc_cache.get().find(&ty_id) { // Must check both caches!
2022+
Some(tc) => { return *tc; }
2023+
None => {}
2024+
}
20162025
}
20172026
cache.insert(ty_id, TC::None);
20182027

0 commit comments

Comments
 (0)