Skip to content

Commit bd7a072

Browse files
committed
rustc: Move the interner over to interior vectors
1 parent b9a2117 commit bd7a072

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/comp/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ fn populate_type_store(&ctxt cx) {
378378
intern(cx, ty_task, none[str]);
379379
intern(cx, ty_type, none[str]);
380380
intern(cx, ty_bot, none[str]);
381-
assert (vec::len(cx.ts.vect) == idx_first_others);
381+
assert (ivec::len(cx.ts.vect) == idx_first_others);
382382
}
383383

384384
fn mk_rcache() -> creader_cache {

src/comp/syntax/util/interner.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// An "interner" is a data structure that associates values with uint tags and
22
// allows bidirectional lookup; i.e. given a value, one can easily find the
33
// type, and vice versa.
4-
import std::vec;
4+
import std::ivec;
55
import std::map;
66
import std::map::hashmap;
77
import std::map::hashfn;
@@ -12,24 +12,24 @@ import std::option::some;
1212

1313
type interner[T] =
1414
rec(hashmap[T, uint] map,
15-
mutable vec[T] vect,
15+
mutable T[] vect,
1616
hashfn[T] hasher,
1717
eqfn[T] eqer);
1818

1919
fn mk[T](hashfn[T] hasher, eqfn[T] eqer) -> interner[T] {
2020
auto m = map::mk_hashmap[T, uint](hasher, eqer);
21-
let vec[T] vect = [];
22-
ret rec(map=m, mutable vect=vect, hasher=hasher, eqer=eqer);
21+
ret rec(map=m, mutable vect=~[], hasher=hasher, eqer=eqer);
2322
}
2423
fn intern[T](&interner[T] itr, &T val) -> uint {
2524
alt (itr.map.find(val)) {
2625
case (some(?idx)) { ret idx; }
2726
case (none) {
28-
auto new_idx = vec::len[T](itr.vect);
27+
auto new_idx = ivec::len[T](itr.vect);
2928
itr.map.insert(val, new_idx);
30-
itr.vect += [val];
29+
itr.vect += ~[val];
3130
ret new_idx;
3231
}
3332
}
3433
}
3534
fn get[T](&interner[T] itr, uint idx) -> T { ret itr.vect.(idx); }
35+

0 commit comments

Comments
 (0)