Skip to content

Commit 917afa4

Browse files
committed
rustc: Remove a bunch of exterior vectors
1 parent a716eb2 commit 917afa4

File tree

18 files changed

+302
-331
lines changed

18 files changed

+302
-331
lines changed

src/comp/back/link.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import middle::ty;
77
import metadata::encoder;
88
import std::str;
99
import std::fs;
10-
import std::vec;
10+
import std::ivec;
1111
import std::option;
1212
import option::some;
1313
import option::none;
@@ -360,10 +360,14 @@ fn build_link_meta(&session::session sess, &ast::crate c,
360360
case (some(?v)) { v }
361361
case (none) {
362362
auto name = {
363-
auto os = str::split(fs::basename(output), '.' as u8);
364-
assert (vec::len(os) >= 2u);
365-
vec::pop(os);
366-
str::connect(os, ".")
363+
auto os_vec = str::split(fs::basename(output), '.' as u8);
364+
// FIXME: Remove this vec->ivec conversion.
365+
auto os = ~[];
366+
for (str s in os_vec) { os += ~[s]; }
367+
368+
assert (ivec::len(os) >= 2u);
369+
ivec::pop(os);
370+
str::connect_ivec(os, ".")
367371
};
368372
warn_missing(sess, "name", name);
369373
name

src/comp/back/upcall.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn declare_upcalls(type_names tn, TypeRef tydesc_type, TypeRef taskptr_type,
6464
ModuleRef llmod)
6565
-> @upcalls {
6666
fn decl(type_names tn, TypeRef tydesc_type, TypeRef taskptr_type,
67-
ModuleRef llmod, str name, vec[TypeRef] tys,
67+
ModuleRef llmod, str name, TypeRef[] tys,
6868
TypeRef rv) -> ValueRef {
6969
let TypeRef[] arg_tys = ~[taskptr_type];
7070
for (TypeRef t in tys) { arg_tys += ~[t]; }
@@ -76,62 +76,62 @@ fn declare_upcalls(type_names tn, TypeRef tydesc_type, TypeRef taskptr_type,
7676
// FIXME: Sigh:.. remove this when I fix the typechecker pushdown.
7777
// --pcwalton
7878

79-
let vec[TypeRef] empty_vec = [];
80-
ret @rec(grow_task=dv("grow_task", [T_size_t()]),
81-
log_int=dv("log_int", [T_i32(), T_i32()]),
82-
log_float=dv("log_float", [T_i32(), T_f32()]),
83-
log_double=dv("log_double", [T_i32(), T_ptr(T_f64())]),
84-
log_str=dv("log_str", [T_i32(), T_ptr(T_str())]),
85-
trace_word=dv("trace_word", [T_int()]),
86-
trace_str=dv("trace_str", [T_ptr(T_i8())]),
87-
new_port=d("new_port", [T_size_t()], T_opaque_port_ptr()),
88-
del_port=dv("del_port", [T_opaque_port_ptr()]),
89-
new_chan=d("new_chan", [T_opaque_port_ptr()],
79+
let TypeRef[] empty_vec = ~[];
80+
ret @rec(grow_task=dv("grow_task", ~[T_size_t()]),
81+
log_int=dv("log_int", ~[T_i32(), T_i32()]),
82+
log_float=dv("log_float", ~[T_i32(), T_f32()]),
83+
log_double=dv("log_double", ~[T_i32(), T_ptr(T_f64())]),
84+
log_str=dv("log_str", ~[T_i32(), T_ptr(T_str())]),
85+
trace_word=dv("trace_word", ~[T_int()]),
86+
trace_str=dv("trace_str", ~[T_ptr(T_i8())]),
87+
new_port=d("new_port", ~[T_size_t()], T_opaque_port_ptr()),
88+
del_port=dv("del_port", ~[T_opaque_port_ptr()]),
89+
new_chan=d("new_chan", ~[T_opaque_port_ptr()],
9090
T_opaque_chan_ptr()),
91-
flush_chan=dv("flush_chan", [T_opaque_chan_ptr()]),
92-
del_chan=dv("del_chan", [T_opaque_chan_ptr()]),
93-
clone_chan=d("clone_chan", [taskptr_type, T_opaque_chan_ptr()],
91+
flush_chan=dv("flush_chan", ~[T_opaque_chan_ptr()]),
92+
del_chan=dv("del_chan", ~[T_opaque_chan_ptr()]),
93+
clone_chan=d("clone_chan", ~[taskptr_type, T_opaque_chan_ptr()],
9494
T_opaque_chan_ptr()),
9595
_yield=dv("yield", empty_vec),
96-
sleep=dv("sleep", [T_size_t()]),
97-
send=dv("send", [T_opaque_chan_ptr(), T_ptr(T_i8())]),
98-
recv=dv("recv", [T_ptr(T_ptr(T_i8())), T_opaque_port_ptr()]),
99-
_fail=dv("fail", [T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
100-
kill=dv("kill", [taskptr_type]),
96+
sleep=dv("sleep", ~[T_size_t()]),
97+
send=dv("send", ~[T_opaque_chan_ptr(), T_ptr(T_i8())]),
98+
recv=dv("recv", ~[T_ptr(T_ptr(T_i8())), T_opaque_port_ptr()]),
99+
_fail=dv("fail", ~[T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
100+
kill=dv("kill", ~[taskptr_type]),
101101
exit=dv("exit", empty_vec),
102-
malloc=d("malloc", [T_size_t(), T_ptr(tydesc_type)],
102+
malloc=d("malloc", ~[T_size_t(), T_ptr(tydesc_type)],
103103
T_ptr(T_i8())),
104-
free=dv("free", [T_ptr(T_i8()), T_int()]),
104+
free=dv("free", ~[T_ptr(T_i8()), T_int()]),
105105
shared_malloc=d("shared_malloc",
106-
[T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
107-
shared_free=dv("shared_free", [T_ptr(T_i8())]),
108-
mark=d("mark", [T_ptr(T_i8())], T_int()),
109-
new_str=d("new_str", [T_ptr(T_i8()), T_size_t()],
106+
~[T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
107+
shared_free=dv("shared_free", ~[T_ptr(T_i8())]),
108+
mark=d("mark", ~[T_ptr(T_i8())], T_int()),
109+
new_str=d("new_str", ~[T_ptr(T_i8()), T_size_t()],
110110
T_ptr(T_str())),
111-
dup_str=d("dup_str", [taskptr_type, T_ptr(T_str())],
111+
dup_str=d("dup_str", ~[taskptr_type, T_ptr(T_str())],
112112
T_ptr(T_str())),
113-
new_vec=d("new_vec", [T_size_t(), T_ptr(tydesc_type)],
113+
new_vec=d("new_vec", ~[T_size_t(), T_ptr(tydesc_type)],
114114
T_opaque_vec_ptr()),
115115
vec_append=d("vec_append",
116-
[T_ptr(tydesc_type), T_ptr(tydesc_type),
117-
T_ptr(T_opaque_vec_ptr()), T_opaque_vec_ptr(),
118-
T_bool()], T_void()),
116+
~[T_ptr(tydesc_type), T_ptr(tydesc_type),
117+
T_ptr(T_opaque_vec_ptr()), T_opaque_vec_ptr(),
118+
T_bool()], T_void()),
119119
get_type_desc=d("get_type_desc",
120-
[T_ptr(T_nil()), T_size_t(), T_size_t(),
121-
T_size_t(), T_ptr(T_ptr(tydesc_type))],
120+
~[T_ptr(T_nil()), T_size_t(), T_size_t(),
121+
T_size_t(), T_ptr(T_ptr(tydesc_type))],
122122
T_ptr(tydesc_type)),
123-
new_task=d("new_task", [T_ptr(T_str())], taskptr_type),
123+
new_task=d("new_task", ~[T_ptr(T_str())], taskptr_type),
124124
start_task=d("start_task",
125-
[taskptr_type, T_int(), T_int(), T_size_t()],
126-
taskptr_type),
127-
ivec_resize=d("ivec_resize", [T_ptr(T_opaque_ivec()), T_int()],
125+
~[taskptr_type, T_int(), T_int(), T_size_t()],
126+
taskptr_type),
127+
ivec_resize=d("ivec_resize", ~[T_ptr(T_opaque_ivec()), T_int()],
128128
T_void()),
129-
ivec_spill=d("ivec_spill", [T_ptr(T_opaque_ivec()), T_int()],
129+
ivec_spill=d("ivec_spill", ~[T_ptr(T_opaque_ivec()), T_int()],
130130
T_void()),
131131
ivec_resize_shared=d("ivec_resize_shared",
132-
[T_ptr(T_opaque_ivec()), T_int()], T_void()),
132+
~[T_ptr(T_opaque_ivec()), T_int()], T_void()),
133133
ivec_spill_shared=d("ivec_spill_shared",
134-
[T_ptr(T_opaque_ivec()), T_int()], T_void()));
134+
~[T_ptr(T_opaque_ivec()), T_int()], T_void()));
135135
}
136136
//
137137
// Local Variables:

src/comp/driver/rustc.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,12 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
301301
@session::options {
302302
auto library = opt_present(match, "lib");
303303
auto static = opt_present(match, "static");
304-
auto library_search_paths = [binary_dir + "/lib"];
305-
library_search_paths += getopts::opt_strs(match, "L");
304+
305+
auto library_search_paths = ~[binary_dir + "/lib"];
306+
// FIXME: Remove this vec->ivec conversion.
307+
auto lsp_vec = getopts::opt_strs(match, "L");
308+
for (str lsp in lsp_vec) { library_search_paths += ~[lsp]; }
309+
306310
auto output_type =
307311
if (opt_present(match, "parse-only")) {
308312
link::output_type_none
@@ -398,7 +402,7 @@ fn opts() -> vec[getopts::opt] {
398402
}
399403

400404
fn main(vec[str] args) {
401-
auto binary = vec::shift[str](args);
405+
auto binary = vec::shift(args);
402406
auto binary_dir = fs::dirname(binary);
403407
auto match =
404408
alt (getopts::getopts(args, opts())) {
@@ -554,7 +558,10 @@ fn main(vec[str] args) {
554558
gcc_args += ["-l" + libarg];
555559
}
556560

557-
gcc_args += cstore::get_used_link_args(cstore);
561+
// FIXME: Remove this ivec->vec conversion.
562+
auto ula = cstore::get_used_link_args(cstore);
563+
for (str arg in ula) { gcc_args += [arg]; }
564+
558565
auto used_libs = cstore::get_used_libraries(cstore);
559566
for (str l in used_libs) {
560567
gcc_args += ["-l" + l];

src/comp/driver/session.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import std::option;
1010
import std::option::some;
1111
import std::option::none;
1212
import std::str;
13-
import std::vec;
1413
import syntax::parse::parser::parse_sess;
1514

1615
tag os { os_win32; os_macos; os_linux; }
@@ -36,14 +35,14 @@ type options =
3635
bool time_passes,
3736
bool time_llvm_passes,
3837
back::link::output_type output_type,
39-
vec[str] library_search_paths,
38+
str[] library_search_paths,
4039
str sysroot,
4140
// The crate config requested for the session, which may be combined
4241
// with additional crate configurations during the compile process
4342
ast::crate_cfg cfg,
4443
bool test);
4544

46-
type crate_metadata = rec(str name, vec[u8] data);
45+
type crate_metadata = rec(str name, u8[] data);
4746

4847
obj session(@config targ_cfg,
4948
@options opts,

src/comp/metadata/creader.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import back::x86;
1414
import util::common;
1515
import std::ivec;
1616
import std::str;
17-
import std::vec;
1817
import std::fs;
1918
import std::ioivec;
2019
import std::option;
@@ -47,7 +46,7 @@ fn read_crates(session::session sess,
4746
type env =
4847
@rec(session::session sess,
4948
@hashmap[str, int] crate_cache,
50-
vec[str] library_search_paths,
49+
str[] library_search_paths,
5150
mutable ast::crate_num next_crate_num);
5251

5352
fn visit_view_item(env e, &@ast::view_item i) {
@@ -128,7 +127,7 @@ fn default_native_lib_naming(session::session sess, bool static) ->
128127

129128
fn find_library_crate(&session::session sess, &ast::ident ident,
130129
&(@ast::meta_item)[] metas,
131-
&vec[str] library_search_paths)
130+
&str[] library_search_paths)
132131
-> option::t[tup(str, @u8[])] {
133132

134133
attr::require_unique_names(sess, metas);
@@ -162,7 +161,7 @@ fn find_library_crate(&session::session sess, &ast::ident ident,
162161

163162
fn find_library_crate_aux(&rec(str prefix, str suffix) nn, str crate_name,
164163
&(@ast::meta_item)[] metas,
165-
&vec[str] library_search_paths) ->
164+
&str[] library_search_paths) ->
166165
option::t[tup(str, @u8[])] {
167166
let str prefix = nn.prefix + crate_name;
168167
// FIXME: we could probably use a 'glob' function in std::fs but it will
@@ -220,7 +219,7 @@ fn get_metadata_section(str filename) -> option::t[@u8[]] {
220219

221220
fn load_library_crate(&session::session sess, span span,
222221
&ast::ident ident, &(@ast::meta_item)[] metas,
223-
&vec[str] library_search_paths) -> tup(str, @u8[]) {
222+
&str[] library_search_paths) -> tup(str, @u8[]) {
224223

225224
alt (find_library_crate(sess, ident, metas, library_search_paths)) {
226225
case (some(?t)) {

src/comp/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn get_type_param_count(&cstore::cstore cstore, &ast::def_id def) -> uint {
2626
}
2727

2828
fn lookup_defs(&cstore::cstore cstore, ast::crate_num cnum,
29-
vec[ast::ident] path) -> vec[ast::def] {
29+
&ast::ident[] path) -> ast::def[] {
3030
auto cdata = cstore::get_crate_data(cstore, cnum).data;
3131
ret decoder::lookup_defs(cdata, cnum, path);
3232
}

src/comp/metadata/cstore.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// The crate store - a central repo for information collected about external
22
// crates and libraries
33

4+
import std::ivec;
45
import std::map;
5-
import std::vec;
66
import std::str;
77
import syntax::ast;
88

@@ -42,9 +42,9 @@ tag cstore {
4242

4343
type cstore_private = @rec(map::hashmap[ast::crate_num, crate_metadata] metas,
4444
use_crate_map use_crate_map,
45-
mutable vec[str] used_crate_files,
46-
mutable vec[str] used_libraries,
47-
mutable vec[str] used_link_args);
45+
mutable str[] used_crate_files,
46+
mutable str[] used_libraries,
47+
mutable str[] used_link_args);
4848

4949
// Map from node_id's of local use statements to crate numbers
5050
type use_crate_map = map::hashmap[ast::node_id, ast::crate_num];
@@ -61,9 +61,9 @@ fn mk_cstore() -> cstore {
6161
auto crate_map = map::new_int_hash[ast::crate_num]();
6262
ret private(@rec(metas = meta_cache,
6363
use_crate_map = crate_map,
64-
mutable used_crate_files = [],
65-
mutable used_libraries = [],
66-
mutable used_link_args = []));
64+
mutable used_crate_files = ~[],
65+
mutable used_libraries = ~[],
66+
mutable used_link_args = ~[]));
6767
}
6868

6969
fn get_crate_data(&cstore cstore, ast::crate_num cnum) -> crate_metadata {
@@ -86,35 +86,39 @@ iter iter_crate_data(&cstore cstore) -> @tup(ast::crate_num, crate_metadata) {
8686
}
8787

8888
fn add_used_crate_file(&cstore cstore, &str lib) {
89-
if (!vec::member(lib, p(cstore).used_crate_files)) {
90-
p(cstore).used_crate_files += [lib];
89+
if (!ivec::member(lib, p(cstore).used_crate_files)) {
90+
p(cstore).used_crate_files += ~[lib];
9191
}
9292
}
9393

94-
fn get_used_crate_files(&cstore cstore) -> vec[str] {
94+
fn get_used_crate_files(&cstore cstore) -> str[] {
9595
ret p(cstore).used_crate_files;
9696
}
9797

9898
fn add_used_library(&cstore cstore, &str lib) -> bool {
9999
if (lib == "") { ret false; }
100100

101-
if (vec::member(lib, p(cstore).used_libraries)) {
101+
if (ivec::member(lib, p(cstore).used_libraries)) {
102102
ret false;
103103
}
104104

105-
p(cstore).used_libraries += [lib];
105+
p(cstore).used_libraries += ~[lib];
106106
ret true;
107107
}
108108

109-
fn get_used_libraries(&cstore cstore) -> vec[str] {
109+
fn get_used_libraries(&cstore cstore) -> str[] {
110110
ret p(cstore).used_libraries;
111111
}
112112

113113
fn add_used_link_args(&cstore cstore, &str args) {
114-
p(cstore).used_link_args += str::split(args, ' ' as u8);
114+
auto used_link_args_vec = str::split(args, ' ' as u8);
115+
// TODO: Remove this vec->ivec conversion.
116+
for (str ula in used_link_args_vec) {
117+
p(cstore).used_link_args += ~[ula];
118+
}
115119
}
116120

117-
fn get_used_link_args(&cstore cstore) -> vec[str] {
121+
fn get_used_link_args(&cstore cstore) -> str[] {
118122
ret p(cstore).used_link_args;
119123
}
120124

0 commit comments

Comments
 (0)