Skip to content

Commit 8552745

Browse files
committed
use Symbol/InternedString in the cache
1 parent f4c183b commit 8552745

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/librustc_trans/symbol_cache.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::cell::RefCell;
12-
use std::rc::Rc;
1311
use rustc::ty::TyCtxt;
12+
use std::cell::RefCell;
13+
use syntax_pos::symbol::{InternedString, Symbol};
1414
use trans_item::TransItem;
1515
use util::nodemap::FxHashMap;
1616

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

2323
pub struct SymbolCache<'a, 'tcx: 'a> {
2424
tcx: TyCtxt<'a, 'tcx, 'tcx>,
25-
index: RefCell<FxHashMap<TransItem<'tcx>, Rc<String>>>,
25+
index: RefCell<FxHashMap<TransItem<'tcx>, Symbol>>,
2626
}
2727

2828
impl<'a, 'tcx> SymbolCache<'a, 'tcx> {
@@ -33,10 +33,10 @@ impl<'a, 'tcx> SymbolCache<'a, 'tcx> {
3333
}
3434
}
3535

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

0 commit comments

Comments
 (0)