Skip to content

Commit 4c38430

Browse files
committed
rustc: Convert bind_params_in_type() to use interior vectors
1 parent 5703bd1 commit 4c38430

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/comp/middle/ty.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,13 +2761,16 @@ fn type_err_to_str(&ty::type_err err) -> str {
27612761
// Converts type parameters in a type to type variables and returns the
27622762
// resulting type along with a list of type variable IDs.
27632763
fn bind_params_in_type(&span sp, &ctxt cx, fn() -> int next_ty_var, t typ,
2764-
uint ty_param_count) -> tup(vec[int], t) {
2765-
let vec[int] param_var_ids = [];
2764+
uint ty_param_count) -> tup(int[], t) {
2765+
let @mutable int[] param_var_ids = @mutable ~[];
27662766
auto i = 0u;
2767-
while (i < ty_param_count) { param_var_ids += [next_ty_var()]; i += 1u; }
2768-
fn binder(span sp, ctxt cx, vec[int] param_var_ids,
2767+
while (i < ty_param_count) {
2768+
*param_var_ids += ~[next_ty_var()];
2769+
i += 1u;
2770+
}
2771+
fn binder(span sp, ctxt cx, @mutable int[] param_var_ids,
27692772
fn() -> int next_ty_var, uint index) -> t {
2770-
if (index < vec::len(param_var_ids)) {
2773+
if (index < ivec::len(*param_var_ids)) {
27712774
ret mk_var(cx, param_var_ids.(index));
27722775
}
27732776
else {
@@ -2777,7 +2780,7 @@ fn bind_params_in_type(&span sp, &ctxt cx, fn() -> int next_ty_var, t typ,
27772780
auto new_typ =
27782781
fold_ty(cx, fm_param(bind binder(sp, cx, param_var_ids,
27792782
next_ty_var, _)), typ);
2780-
ret tup(param_var_ids, new_typ);
2783+
ret tup(*param_var_ids, new_typ);
27812784
}
27822785

27832786

0 commit comments

Comments
 (0)