Skip to content

Commit

Permalink
use Symbol/InternedString in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 21, 2017
1 parent f4c183b commit 8552745
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/librustc_trans/symbol_cache.rs
Expand Up @@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::cell::RefCell;
use std::rc::Rc;
use rustc::ty::TyCtxt;
use std::cell::RefCell;
use syntax_pos::symbol::{InternedString, Symbol};
use trans_item::TransItem;
use util::nodemap::FxHashMap;

Expand All @@ -22,7 +22,7 @@ use util::nodemap::FxHashMap;

pub struct SymbolCache<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
index: RefCell<FxHashMap<TransItem<'tcx>, Rc<String>>>,
index: RefCell<FxHashMap<TransItem<'tcx>, Symbol>>,
}

impl<'a, 'tcx> SymbolCache<'a, 'tcx> {
Expand All @@ -33,10 +33,10 @@ impl<'a, 'tcx> SymbolCache<'a, 'tcx> {
}
}

pub fn get(&self, trans_item: TransItem<'tcx>) -> Rc<String> {
pub fn get(&self, trans_item: TransItem<'tcx>) -> InternedString {
let mut index = self.index.borrow_mut();
index.entry(trans_item)
.or_insert_with(|| Rc::new(trans_item.compute_symbol_name(self.tcx)))
.clone()
.or_insert_with(|| Symbol::intern(&trans_item.compute_symbol_name(self.tcx)))
.as_str()
}
}

0 comments on commit 8552745

Please sign in to comment.