libsyntax: De-@mut SCTable::mark_memo

This commit is contained in:
Patrick Walton 2013-12-27 16:38:25 -08:00
parent be17a1b08c
commit 4d6dde7f49
2 changed files with 8 additions and 7 deletions

View file

@ -89,9 +89,9 @@ fn ne(&self, other: &Ident) -> bool {
// it should cut down on memory use *a lot*; applying a mark
// to a tree containing 50 identifiers would otherwise generate
pub struct SCTable {
table : RefCell<~[SyntaxContext_]>,
mark_memo : HashMap<(SyntaxContext,Mrk),SyntaxContext>,
rename_memo : HashMap<(SyntaxContext,Ident,Name),SyntaxContext>
table: RefCell<~[SyntaxContext_]>,
mark_memo: RefCell<HashMap<(SyntaxContext,Mrk),SyntaxContext>>,
rename_memo: HashMap<(SyntaxContext,Ident,Name),SyntaxContext>
}
// NB: these must be placed in any SCTable...

View file

@ -717,17 +717,18 @@ pub fn new_mark_internal(m:Mrk, tail:SyntaxContext,table:&mut SCTable)
// flow-sensitivity. Results in two lookups on a hash table hit.
// also applies to new_rename_internal, below.
// let try_lookup = table.mark_memo.find(&key);
match table.mark_memo.contains_key(&key) {
let mut mark_memo = table.mark_memo.borrow_mut();
match mark_memo.get().contains_key(&key) {
false => {
let new_idx = {
let mut table = table.table.borrow_mut();
idx_push(table.get(), Mark(m,tail))
};
table.mark_memo.insert(key,new_idx);
mark_memo.get().insert(key,new_idx);
new_idx
}
true => {
match table.mark_memo.find(&key) {
match mark_memo.get().find(&key) {
None => fail!("internal error: key disappeared 2013042901"),
Some(idxptr) => {*idxptr}
}
@ -771,7 +772,7 @@ pub fn new_rename_internal(id:Ident, to:Name, tail:SyntaxContext, table: &mut SC
pub fn new_sctable_internal() -> SCTable {
SCTable {
table: RefCell::new(~[EmptyCtxt,IllegalCtxt]),
mark_memo: HashMap::new(),
mark_memo: RefCell::new(HashMap::new()),
rename_memo: HashMap::new()
}
}