Skip to content

Commit ed85de4

Browse files
committed
---
yaml --- r: 2438 b: refs/heads/master c: 17daf1f h: refs/heads/master v: v3
1 parent 8a30d23 commit ed85de4

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 3bec4c8193bc6d6d8ea798bab01c30b46dc8163c
2+
refs/heads/master: 17daf1f9bf4e78c9f3ed8be24ef4bc15d60c744e

trunk/src/comp/middle/metadata.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,19 @@ mod Encode {
8282

8383
fn enc_ty(&IO.writer w, &@ctxt cx, &ty.t t) {
8484
alt (cx.abbrevs) {
85-
case (ac_no_abbrevs) { enc_sty(w, cx, ty.struct(cx.tcx, t)); }
85+
case (ac_no_abbrevs) {
86+
auto result_str;
87+
alt (cx.tcx.short_names_cache.find(t)) {
88+
case (some[str](?s)) { result_str = s; }
89+
case (none[str]) {
90+
auto sw = IO.string_writer();
91+
enc_sty(sw.get_writer(), cx, ty.struct(cx.tcx, t));
92+
result_str = sw.get_str();
93+
cx.tcx.short_names_cache.insert(t, result_str);
94+
}
95+
}
96+
w.write_str(result_str);
97+
}
8698
case (ac_use_abbrevs(?abbrevs)) {
8799
alt (abbrevs.find(t)) {
88100
case (some[ty_abbrev](?a)) {

trunk/src/comp/middle/trans.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ state type crate_ctxt = rec(session.session sess,
113113
std.SHA1.sha1 sha,
114114
hashmap[ty.t, str] type_sha1s,
115115
hashmap[ty.t, metadata.ty_abbrev] type_abbrevs,
116+
hashmap[ty.t, str] type_short_names,
116117
ty.ctxt tcx,
117118
@upcall.upcalls upcalls);
118119

@@ -192,6 +193,7 @@ fn get_type_sha1(@crate_ctxt ccx, ty.t t) -> str {
192193
// NB: do *not* use abbrevs here as we want the symbol names
193194
// to be independent of one another in the crate.
194195
auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata.ac_no_abbrevs);
196+
195197
ccx.sha.input_str(metadata.Encode.ty_str(cx, t));
196198
hash = Str.substr(ccx.sha.result_str(), 0u, 16u);
197199
ccx.type_sha1s.insert(t, hash);
@@ -7694,6 +7696,7 @@ fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx,
76947696
auto lltypes = Map.mk_hashmap[ty.t,TypeRef](hasher, eqer);
76957697
auto sha1s = Map.mk_hashmap[ty.t,str](hasher, eqer);
76967698
auto abbrevs = Map.mk_hashmap[ty.t,metadata.ty_abbrev](hasher, eqer);
7699+
auto short_names = Map.mk_hashmap[ty.t,str](hasher, eqer);
76977700

76987701
auto ccx = @rec(sess = sess,
76997702
llmod = llmod,
@@ -7721,6 +7724,7 @@ fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx,
77217724
sha = std.SHA1.mk_sha1(),
77227725
type_sha1s = sha1s,
77237726
type_abbrevs = abbrevs,
7727+
type_short_names = short_names,
77247728
tcx = tcx,
77257729
upcalls = upcall.declare_upcalls(tn, llmod));
77267730
auto cx = new_local_ctxt(ccx);

trunk/src/comp/middle/ty.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ type mt = rec(t ty, ast.mutability mut);
5555
type creader_cache = hashmap[tup(int,uint,uint),ty.t];
5656
type ctxt = rec(@type_store ts,
5757
session.session sess,
58-
creader_cache rcache);
58+
creader_cache rcache,
59+
hashmap[t,str] short_names_cache);
5960
type ty_ctxt = ctxt; // Needed for disambiguation from Unify.ctxt.
6061

6162
// Convert from method type to function type. Pretty easy; we just drop
@@ -227,7 +228,9 @@ fn mk_rcache() -> creader_cache {
227228
fn mk_ctxt(session.session s) -> ctxt {
228229
ret rec(ts = mk_type_store(),
229230
sess = s,
230-
rcache = mk_rcache());
231+
rcache = mk_rcache(),
232+
short_names_cache =
233+
Map.mk_hashmap[ty.t,str](ty.hash_ty, ty.eq_ty));
231234
}
232235
// Type constructors
233236

0 commit comments

Comments
 (0)