Skip to content

Commit 0e2041c

Browse files
committed
librustc: De-@mut CrateContext::const_cstr_cache.
1 parent 13f85cb commit 0e2041c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/librustc/middle/trans/common.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,12 @@ pub fn C_u8(i: uint) -> ValueRef {
890890
// our boxed-and-length-annotated strings.
891891
pub fn C_cstr(cx: &mut CrateContext, s: @str) -> ValueRef {
892892
unsafe {
893-
match cx.const_cstr_cache.find_equiv(&s) {
894-
Some(&llval) => return llval,
895-
None => ()
893+
{
894+
let const_cstr_cache = cx.const_cstr_cache.borrow();
895+
match const_cstr_cache.get().find_equiv(&s) {
896+
Some(&llval) => return llval,
897+
None => ()
898+
}
896899
}
897900

898901
let sc = llvm::LLVMConstStringInContext(cx.llcx,
@@ -907,9 +910,9 @@ pub fn C_cstr(cx: &mut CrateContext, s: @str) -> ValueRef {
907910
llvm::LLVMSetGlobalConstant(g, True);
908911
lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
909912

910-
cx.const_cstr_cache.insert(s, g);
911-
912-
return g;
913+
let mut const_cstr_cache = cx.const_cstr_cache.borrow_mut();
914+
const_cstr_cache.get().insert(s, g);
915+
g
913916
}
914917
}
915918

src/librustc/middle/trans/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub struct CrateContext {
7171
// Cache generated vtables
7272
vtables: RefCell<HashMap<(ty::t, mono_id), ValueRef>>,
7373
// Cache of constant strings,
74-
const_cstr_cache: HashMap<@str, ValueRef>,
74+
const_cstr_cache: RefCell<HashMap<@str, ValueRef>>,
7575

7676
// Reverse-direction for const ptrs cast from globals.
7777
// Key is an int, cast from a ValueRef holding a *T,
@@ -197,7 +197,7 @@ impl CrateContext {
197197
monomorphized: RefCell::new(HashMap::new()),
198198
monomorphizing: RefCell::new(HashMap::new()),
199199
vtables: RefCell::new(HashMap::new()),
200-
const_cstr_cache: HashMap::new(),
200+
const_cstr_cache: RefCell::new(HashMap::new()),
201201
const_globals: HashMap::new(),
202202
const_values: HashMap::new(),
203203
extern_const_values: HashMap::new(),

0 commit comments

Comments
 (0)