File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -60,17 +60,27 @@ fn mywrite(w: @mut MemWriter, fmt: &fmt::Arguments) {
60
60
pub fn enc_ty ( w : @mut MemWriter , cx : @ctxt , t : ty:: t ) {
61
61
match cx. abbrevs {
62
62
ac_no_abbrevs => {
63
- let result_str = match cx. tcx . short_names_cache . find ( & t) {
64
- Some ( & s) => s,
63
+ let result_str_opt;
64
+ {
65
+ let short_names_cache = cx. tcx . short_names_cache . borrow ( ) ;
66
+ result_str_opt = short_names_cache. get ( )
67
+ . find ( & t)
68
+ . map ( |result| * result) ;
69
+ }
70
+ let result_str = match result_str_opt {
71
+ Some ( s) => s,
65
72
None => {
66
73
let wr = @mut MemWriter :: new ( ) ;
67
74
enc_sty ( wr, cx, & ty:: get ( t) . sty ) ;
68
75
let s = str:: from_utf8 ( * wr. inner_ref ( ) ) . to_managed ( ) ;
69
- cx. tcx . short_names_cache . insert ( t, s) ;
76
+ let mut short_names_cache = cx. tcx
77
+ . short_names_cache
78
+ . borrow_mut ( ) ;
79
+ short_names_cache. get ( ) . insert ( t, s) ;
70
80
s
71
- }
72
- } ;
73
- w. write ( result_str. as_bytes ( ) ) ;
81
+ }
82
+ } ;
83
+ w. write ( result_str. as_bytes ( ) ) ;
74
84
}
75
85
ac_use_abbrevs( abbrevs) => {
76
86
match abbrevs. find ( & t) {
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ struct ctxt_ {
307
307
freevars : freevars:: freevar_map ,
308
308
tcache : type_cache ,
309
309
rcache : creader_cache ,
310
- short_names_cache : @ mut HashMap < t , @str > ,
310
+ short_names_cache : RefCell < HashMap < t , @str > > ,
311
311
needs_unwind_cleanup_cache : @mut HashMap < t , bool > ,
312
312
tc_cache : @mut HashMap < uint , TypeContents > ,
313
313
ast_ty_to_ty_cache : @mut HashMap < NodeId , ast_ty_to_ty_cache_entry > ,
@@ -993,7 +993,7 @@ pub fn mk_ctxt(s: session::Session,
993
993
freevars : freevars,
994
994
tcache : @mut HashMap :: new ( ) ,
995
995
rcache : mk_rcache ( ) ,
996
- short_names_cache : new_ty_hash ( ) ,
996
+ short_names_cache : RefCell :: new ( HashMap :: new ( ) ) ,
997
997
needs_unwind_cleanup_cache : new_ty_hash ( ) ,
998
998
tc_cache : @mut HashMap :: new ( ) ,
999
999
ast_ty_to_ty_cache : @mut HashMap :: new ( ) ,
You can’t perform that action at this time.
0 commit comments