Skip to content

Commit 00c1437

Browse files
committed
---
yaml --- r: 4983 b: refs/heads/master c: b2408d5 h: refs/heads/master i: 4981: 6aad0cf 4979: b09c5e0 4975: 87c24bd v: v3
1 parent 5f34d4e commit 00c1437

File tree

9 files changed

+67
-61
lines changed

9 files changed

+67
-61
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: fcc031c5b4dc8f64c497b8dd1e066068e862bd72
2+
refs/heads/master: b2408d57f034c0a448b60bf03254d8f73c0882db

trunk/src/comp/back/link.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, link_meta: &link_meta) ->
412412
// FIXME: This wants to be link_meta.meta_hash
413413
sha.input_str(istr::from_estr(link_meta.name));
414414
sha.input_str(~"-");
415-
sha.input_str(istr::from_estr(encoder::encoded_ty(tcx, t)));
415+
sha.input_str(encoder::encoded_ty(tcx, t));
416416
let hash = truncated_sha1_result(sha);
417417
// Prefix with _ so that it never blends into adjacent digits
418418
@@ -458,7 +458,7 @@ fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: ty::t, name: &str)
458458
-> str {
459459
let s = util::ppaux::ty_to_short_str(ccx.tcx, t);
460460
let hash = get_symbol_hash(ccx, t);
461-
ret mangle([name, s, hash]);
461+
ret mangle([name, istr::to_estr(s), hash]);
462462
}
463463

464464
fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[str],

trunk/src/comp/metadata/common.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// EBML tag definitions and utils shared by the encoder and decoder
22

3-
import std::str;
3+
import std::istr;
44

55
const tag_paths: uint = 0x01u;
66

@@ -67,9 +67,9 @@ const tag_items_data_item_inlineness: uint = 0x27u;
6767
// djb's cdb hashes.
6868
fn hash_node_id(node_id: &int) -> uint { ret 177573u ^ (node_id as uint); }
6969

70-
fn hash_path(s: &str) -> uint {
70+
fn hash_path(s: &istr) -> uint {
7171
let h = 5381u;
72-
for ch: u8 in str::bytes(s) { h = (h << 5u) + h ^ (ch as uint); }
72+
for ch: u8 in istr::bytes(s) { h = (h << 5u) + h ^ (ch as uint); }
7373
ret h;
7474
}
7575

trunk/src/comp/metadata/decoder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ fn resolve_path(path: &[ast::ident], data: @[u8]) -> [ast::def_id] {
158158
let paths = ebml::get_doc(md, tag_paths);
159159
let eqer = bind eq_item(_, s);
160160
let result: [ast::def_id] = [];
161-
for doc: ebml::doc in lookup_hash(paths, eqer, hash_path(s)) {
161+
for doc: ebml::doc in lookup_hash(paths, eqer,
162+
hash_path(istr::from_estr(s))) {
162163
let did_doc = ebml::get_doc(doc, tag_def_id);
163164
result += [parse_def_id(ebml::doc_data(did_doc))];
164165
}

trunk/src/comp/metadata/encoder.rs

+47-43
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ type abbrev_map = map::hashmap<ty::t, tyencode::ty_abbrev>;
2727
type encode_ctxt = {ccx: @crate_ctxt, type_abbrevs: abbrev_map};
2828

2929
// Path table encoding
30-
fn encode_name(ebml_w: &ebml::writer, name: &str) {
30+
fn encode_name(ebml_w: &ebml::writer, name: &istr) {
3131
ebml::start_tag(ebml_w, tag_paths_data_name);
32-
ebml_w.writer.write(str::bytes(name));
32+
ebml_w.writer.write(istr::bytes(name));
3333
ebml::end_tag(ebml_w);
3434
}
3535

@@ -42,117 +42,121 @@ fn encode_def_id(ebml_w: &ebml::writer, id: &def_id) {
4242
type entry<T> = {val: T, pos: uint};
4343

4444
fn encode_tag_variant_paths(ebml_w: &ebml::writer, variants: &[variant],
45-
path: &[str], index: &mutable [entry<str>]) {
45+
path: &[istr], index: &mutable [entry<istr>]) {
4646
for variant: variant in variants {
47-
add_to_index(ebml_w, path, index, variant.node.name);
47+
add_to_index(ebml_w, path, index, istr::from_estr(variant.node.name));
4848
ebml::start_tag(ebml_w, tag_paths_data_item);
49-
encode_name(ebml_w, variant.node.name);
49+
encode_name(ebml_w, istr::from_estr(variant.node.name));
5050
encode_def_id(ebml_w, local_def(variant.node.id));
5151
ebml::end_tag(ebml_w);
5252
}
5353
}
5454

55-
fn add_to_index(ebml_w: &ebml::writer, path: &[str],
56-
index: &mutable [entry<str>], name: &str) {
55+
fn add_to_index(ebml_w: &ebml::writer, path: &[istr],
56+
index: &mutable [entry<istr>], name: &istr) {
5757
let full_path = path + [name];
5858
index +=
59-
[{val: str::connect(full_path, "::"), pos: ebml_w.writer.tell()}];
59+
[{val: istr::connect(full_path, ~"::"), pos: ebml_w.writer.tell()}];
6060
}
6161

6262
fn encode_native_module_item_paths(ebml_w: &ebml::writer, nmod: &native_mod,
63-
path: &[str],
64-
index: &mutable [entry<str>]) {
63+
path: &[istr],
64+
index: &mutable [entry<istr>]) {
6565
for nitem: @native_item in nmod.items {
66-
add_to_index(ebml_w, path, index, nitem.ident);
66+
add_to_index(ebml_w, path, index, istr::from_estr(nitem.ident));
6767
ebml::start_tag(ebml_w, tag_paths_data_item);
68-
encode_name(ebml_w, nitem.ident);
68+
encode_name(ebml_w, istr::from_estr(nitem.ident));
6969
encode_def_id(ebml_w, local_def(nitem.id));
7070
ebml::end_tag(ebml_w);
7171
}
7272
}
7373

7474
fn encode_module_item_paths(ebml_w: &ebml::writer, module: &_mod,
75-
path: &[str], index: &mutable [entry<str>]) {
75+
path: &[istr], index: &mutable [entry<istr>]) {
7676
for it: @item in module.items {
7777
if !ast_util::is_exported(it.ident, module) { cont; }
7878
alt it.node {
7979
item_const(_, _) {
80-
add_to_index(ebml_w, path, index, it.ident);
80+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
8181
ebml::start_tag(ebml_w, tag_paths_data_item);
82-
encode_name(ebml_w, it.ident);
82+
encode_name(ebml_w, istr::from_estr(it.ident));
8383
encode_def_id(ebml_w, local_def(it.id));
8484
ebml::end_tag(ebml_w);
8585
}
8686
item_fn(_, tps) {
87-
add_to_index(ebml_w, path, index, it.ident);
87+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
8888
ebml::start_tag(ebml_w, tag_paths_data_item);
89-
encode_name(ebml_w, it.ident);
89+
encode_name(ebml_w, istr::from_estr(it.ident));
9090
encode_def_id(ebml_w, local_def(it.id));
9191
ebml::end_tag(ebml_w);
9292
}
9393
item_mod(_mod) {
94-
add_to_index(ebml_w, path, index, it.ident);
94+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
9595
ebml::start_tag(ebml_w, tag_paths_data_mod);
96-
encode_name(ebml_w, it.ident);
96+
encode_name(ebml_w, istr::from_estr(it.ident));
9797
encode_def_id(ebml_w, local_def(it.id));
98-
encode_module_item_paths(ebml_w, _mod, path + [it.ident], index);
98+
encode_module_item_paths(ebml_w, _mod,
99+
path + [istr::from_estr(it.ident)],
100+
index);
99101
ebml::end_tag(ebml_w);
100102
}
101103
item_native_mod(nmod) {
102-
add_to_index(ebml_w, path, index, it.ident);
104+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
103105
ebml::start_tag(ebml_w, tag_paths_data_mod);
104-
encode_name(ebml_w, it.ident);
106+
encode_name(ebml_w, istr::from_estr(it.ident));
105107
encode_def_id(ebml_w, local_def(it.id));
106-
encode_native_module_item_paths(ebml_w, nmod, path + [it.ident],
107-
index);
108+
encode_native_module_item_paths(
109+
ebml_w, nmod,
110+
path + [istr::from_estr(it.ident)],
111+
index);
108112
ebml::end_tag(ebml_w);
109113
}
110114
item_ty(_, tps) {
111-
add_to_index(ebml_w, path, index, it.ident);
115+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
112116
ebml::start_tag(ebml_w, tag_paths_data_item);
113-
encode_name(ebml_w, it.ident);
117+
encode_name(ebml_w, istr::from_estr(it.ident));
114118
encode_def_id(ebml_w, local_def(it.id));
115119
ebml::end_tag(ebml_w);
116120
}
117121
item_res(_, _, tps, ctor_id) {
118-
add_to_index(ebml_w, path, index, it.ident);
122+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
119123
ebml::start_tag(ebml_w, tag_paths_data_item);
120-
encode_name(ebml_w, it.ident);
124+
encode_name(ebml_w, istr::from_estr(it.ident));
121125
encode_def_id(ebml_w, local_def(ctor_id));
122126
ebml::end_tag(ebml_w);
123-
add_to_index(ebml_w, path, index, it.ident);
127+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
124128
ebml::start_tag(ebml_w, tag_paths_data_item);
125-
encode_name(ebml_w, it.ident);
129+
encode_name(ebml_w, istr::from_estr(it.ident));
126130
encode_def_id(ebml_w, local_def(it.id));
127131
ebml::end_tag(ebml_w);
128132
}
129133
item_tag(variants, tps) {
130-
add_to_index(ebml_w, path, index, it.ident);
134+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
131135
ebml::start_tag(ebml_w, tag_paths_data_item);
132-
encode_name(ebml_w, it.ident);
136+
encode_name(ebml_w, istr::from_estr(it.ident));
133137
encode_def_id(ebml_w, local_def(it.id));
134138
ebml::end_tag(ebml_w);
135139
encode_tag_variant_paths(ebml_w, variants, path, index);
136140
}
137141
item_obj(_, tps, ctor_id) {
138-
add_to_index(ebml_w, path, index, it.ident);
142+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
139143
ebml::start_tag(ebml_w, tag_paths_data_item);
140-
encode_name(ebml_w, it.ident);
144+
encode_name(ebml_w, istr::from_estr(it.ident));
141145
encode_def_id(ebml_w, local_def(ctor_id));
142146
ebml::end_tag(ebml_w);
143-
add_to_index(ebml_w, path, index, it.ident);
147+
add_to_index(ebml_w, path, index, istr::from_estr(it.ident));
144148
ebml::start_tag(ebml_w, tag_paths_data_item);
145-
encode_name(ebml_w, it.ident);
149+
encode_name(ebml_w, istr::from_estr(it.ident));
146150
encode_def_id(ebml_w, local_def(it.id));
147151
ebml::end_tag(ebml_w);
148152
}
149153
}
150154
}
151155
}
152156

153-
fn encode_item_paths(ebml_w: &ebml::writer, crate: &@crate) -> [entry<str>] {
154-
let index: [entry<str>] = [];
155-
let path: [str] = [];
157+
fn encode_item_paths(ebml_w: &ebml::writer, crate: &@crate) -> [entry<istr>] {
158+
let index: [entry<istr>] = [];
159+
let path: [istr] = [];
156160
ebml::start_tag(ebml_w, tag_paths);
157161
encode_module_item_paths(ebml_w, crate.node.module, path, index);
158162
ebml::end_tag(ebml_w);
@@ -436,8 +440,8 @@ fn encode_index<T>(ebml_w: &ebml::writer, buckets: &[@[entry<T>]],
436440
ebml::end_tag(ebml_w);
437441
}
438442

439-
fn write_str(writer: &io::writer, s: &str) {
440-
writer.write_str(istr::from_estr(s));
443+
fn write_str(writer: &io::writer, s: &istr) {
444+
writer.write_str(s);
441445
}
442446

443447
fn write_int(writer: &io::writer, n: &int) {
@@ -623,11 +627,11 @@ fn encode_metadata(cx: &@crate_ctxt, crate: &@crate) -> str {
623627
}
624628

625629
// Get the encoded string for a type
626-
fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> str {
630+
fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> istr {
627631
let cx = @{ds: def_to_str, tcx: tcx, abbrevs: tyencode::ac_no_abbrevs};
628632
let sw = io::string_writer();
629633
tyencode::enc_ty(sw.get_writer(), cx, t);
630-
ret istr::to_estr(sw.get_str());
634+
ret sw.get_str();
631635
}
632636

633637

trunk/src/comp/metadata/tyencode.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ctxt =
2626
// Compact string representation for ty.t values. API ty_str & parse_from_str.
2727
// Extra parameters are for converting to/from def_ids in the string rep.
2828
// Whatever format you choose should not contain pipe characters.
29-
type ty_abbrev = {pos: uint, len: uint, s: str};
29+
type ty_abbrev = {pos: uint, len: uint, s: @istr};
3030

3131
tag abbrev_ctxt { ac_no_abbrevs; ac_use_abbrevs(hashmap<ty::t, ty_abbrev>); }
3232

@@ -40,21 +40,21 @@ fn cx_uses_abbrevs(cx: &@ctxt) -> bool {
4040
fn enc_ty(w: &io::writer, cx: &@ctxt, t: ty::t) {
4141
alt cx.abbrevs {
4242
ac_no_abbrevs. {
43-
let result_str;
43+
let result_str: @istr;
4444
alt cx.tcx.short_names_cache.find(t) {
4545
some(s) { result_str = s; }
4646
none. {
4747
let sw = io::string_writer();
4848
enc_sty(sw.get_writer(), cx, ty::struct(cx.tcx, t));
49-
result_str = istr::to_estr(sw.get_str());
49+
result_str = @sw.get_str();
5050
cx.tcx.short_names_cache.insert(t, result_str);
5151
}
5252
}
53-
w.write_str(istr::from_estr(result_str));
53+
w.write_str(*result_str);
5454
}
5555
ac_use_abbrevs(abbrevs) {
5656
alt abbrevs.find(t) {
57-
some(a) { w.write_str(istr::from_estr(a.s)); ret; }
57+
some(a) { w.write_str(*a.s); ret; }
5858
none. {
5959
let pos = w.get_buf_writer().tell();
6060
enc_sty(w, cx, ty::struct(cx.tcx, t));
@@ -73,7 +73,7 @@ fn enc_ty(w: &io::writer, cx: &@ctxt, t: ty::t) {
7373
let s =
7474
~"#" + uint::to_str(pos, 16u) + ~":" +
7575
uint::to_str(len, 16u) + ~"#";
76-
let a = {pos: pos, len: len, s: istr::to_estr(s)};
76+
let a = {pos: pos, len: len, s: @s};
7777
abbrevs.insert(t, a);
7878
}
7979
ret;

trunk/src/comp/middle/trans.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,8 @@ fn make_generic_glue(cx: &@local_ctxt, sp: &span, t: ty::t, llfn: ValueRef,
12321232
let start = time::get_time();
12331233
let llval = make_generic_glue_inner(cx, sp, t, llfn, helper, ty_params);
12341234
let end = time::get_time();
1235-
log_fn_time(cx.ccx, "glue " + name + " " + ty_to_short_str(cx.ccx.tcx, t),
1235+
log_fn_time(cx.ccx, "glue " + name + " " +
1236+
istr::to_estr(ty_to_short_str(cx.ccx.tcx, t)),
12361237
start, end);
12371238
ret llval;
12381239
}

trunk/src/comp/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ type ctxt =
223223
freevars: freevars::freevar_map,
224224
tcache: type_cache,
225225
rcache: creader_cache,
226-
short_names_cache: hashmap<t, str>,
226+
short_names_cache: hashmap<t, @istr>,
227227
has_pointer_cache: hashmap<t, bool>,
228228
kind_cache: hashmap<t, ast::kind>,
229229
owns_heap_mem_cache: hashmap<t, bool>,

trunk/src/comp/util/ppaux.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
147147
ty_param(id, _) {
148148
"'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)])
149149
}
150-
_ { ty_to_short_str(cx, typ) }
150+
_ { istr::to_estr(ty_to_short_str(cx, typ)) }
151151
}
152152
}
153153

154-
fn ty_to_short_str(cx: &ctxt, typ: t) -> str {
154+
fn ty_to_short_str(cx: &ctxt, typ: t) -> istr {
155155
let s = encoder::encoded_ty(cx, typ);
156-
if str::byte_len(s) >= 32u { s = str::substr(s, 0u, 32u); }
156+
if istr::byte_len(s) >= 32u { s = istr::substr(s, 0u, 32u); }
157157
ret s;
158158
}
159159

0 commit comments

Comments
 (0)