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 @@ pub type SyntaxContext = u32;
// it should cut down on memory use *a lot*; applying a mark // it should cut down on memory use *a lot*; applying a mark
// to a tree containing 50 identifiers would otherwise generate // to a tree containing 50 identifiers would otherwise generate
pub struct SCTable { pub struct SCTable {
table : RefCell<~[SyntaxContext_]>, table: RefCell<~[SyntaxContext_]>,
mark_memo : HashMap<(SyntaxContext,Mrk),SyntaxContext>, mark_memo: RefCell<HashMap<(SyntaxContext,Mrk),SyntaxContext>>,
rename_memo : HashMap<(SyntaxContext,Ident,Name),SyntaxContext> rename_memo: HashMap<(SyntaxContext,Ident,Name),SyntaxContext>
} }
// NB: these must be placed in any SCTable... // 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. // flow-sensitivity. Results in two lookups on a hash table hit.
// also applies to new_rename_internal, below. // also applies to new_rename_internal, below.
// let try_lookup = table.mark_memo.find(&key); // 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 => { false => {
let new_idx = { let new_idx = {
let mut table = table.table.borrow_mut(); let mut table = table.table.borrow_mut();
idx_push(table.get(), Mark(m,tail)) idx_push(table.get(), Mark(m,tail))
}; };
table.mark_memo.insert(key,new_idx); mark_memo.get().insert(key,new_idx);
new_idx new_idx
} }
true => { true => {
match table.mark_memo.find(&key) { match mark_memo.get().find(&key) {
None => fail!("internal error: key disappeared 2013042901"), None => fail!("internal error: key disappeared 2013042901"),
Some(idxptr) => {*idxptr} 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 { pub fn new_sctable_internal() -> SCTable {
SCTable { SCTable {
table: RefCell::new(~[EmptyCtxt,IllegalCtxt]), table: RefCell::new(~[EmptyCtxt,IllegalCtxt]),
mark_memo: HashMap::new(), mark_memo: RefCell::new(HashMap::new()),
rename_memo: HashMap::new() rename_memo: HashMap::new()
} }
} }