Skip to content

Commit 371dddb

Browse files
committed
---
yaml --- r: 3260 b: refs/heads/master c: 3f7380c h: refs/heads/master v: v3
1 parent dd2f729 commit 371dddb

File tree

5 files changed

+21
-29
lines changed

5 files changed

+21
-29
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: 8cdef277b24e11ab48932c38a14aaa5bd5f19bfe
2+
refs/heads/master: 3f7380ccec2ebb7809b05d43d6241206650ab02b

trunk/src/comp/middle/ty.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ type type_store = interner::interner[raw_t];
352352
type ty_param_substs_opt_and_ty = tup(option::t[vec[ty::t]], ty::t);
353353

354354
type node_type_table =
355-
@mutable vec[mutable option::t[ty::ty_param_substs_opt_and_ty]];
355+
@smallintmap::smallintmap[ty::ty_param_substs_opt_and_ty];
356356

357357
fn populate_type_store(&ctxt cx) {
358358
intern(cx, ty_nil, none[str]);
@@ -394,9 +394,8 @@ fn mk_rcache() -> creader_cache {
394394
}
395395

396396
fn mk_ctxt(session::session s, resolve::def_map dm, constr_table cs) -> ctxt {
397-
let vec[mutable option::t[ty::ty_param_substs_opt_and_ty]] ntt_sub =
398-
[mutable ];
399-
let node_type_table ntt = @mutable ntt_sub;
397+
let node_type_table ntt =
398+
@smallintmap::mk[ty::ty_param_substs_opt_and_ty]();
400399
auto tcache = new_def_hash[ty::ty_param_count_and_ty]();
401400
auto items = new_def_hash[any_item]();
402401
auto ts = @interner::mk[raw_t](hash_raw_ty, eq_raw_ty);
@@ -1597,7 +1596,7 @@ fn ann_to_ty_param_substs_opt_and_ty(&ctxt cx, &ast::ann ann) ->
15971596
ty_param_substs_opt_and_ty {
15981597

15991598
// Pull out the node type table.
1600-
alt ({ cx.node_types.(ann.id) }) {
1599+
alt (smallintmap::find(*cx.node_types, ann.id)) {
16011600
case (none) {
16021601
cx.sess.bug("ann_to_ty_param_substs_opt_and_ty() called on an " +
16031602
"untyped node");

trunk/src/comp/middle/typeck.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import std::option;
4242
import std::option::none;
4343
import std::option::some;
4444
import std::option::from_maybe;
45+
import std::smallintmap;
4546
import middle::tstate::ann::ts_ann;
4647

4748
type ty_table = hashmap[ast::def_id, ty::t];
@@ -385,12 +386,7 @@ fn ast_ty_to_ty_crate(@crate_ctxt ccx, &@ast::ty ast_ty) -> ty::t {
385386
mod write {
386387
fn inner(&node_type_table ntt, uint node_id,
387388
&ty_param_substs_opt_and_ty tpot) {
388-
auto ntt_ = *ntt;
389-
vec::grow_set(ntt_,
390-
node_id,
391-
none[ty_param_substs_opt_and_ty],
392-
some[ty_param_substs_opt_and_ty](tpot));
393-
*ntt = ntt_;
389+
smallintmap::insert(*ntt, node_id, tpot);
394390
}
395391

396392
// Writes a type parameter count and type pair into the node type table.
@@ -1173,13 +1169,6 @@ fn replace_expr_type(&@fn_ctxt fcx, &@ast::expr expr,
11731169
write::ty_fixup(fcx, ty::expr_ann(expr).id, tup(new_tps, new_tyt._1));
11741170
}
11751171

1176-
fn replace_node_type_only(&ty::ctxt tcx, uint fixup, ty::t new_t) {
1177-
auto fixup_opt = tcx.node_types.(fixup);
1178-
auto tps = option::get[ty::ty_param_substs_opt_and_ty](fixup_opt)._0;
1179-
tcx.node_types.(fixup) =
1180-
some[ty::ty_param_substs_opt_and_ty](tup(tps, new_t));
1181-
}
1182-
11831172

11841173
// AST fragment checking
11851174
fn check_lit(@crate_ctxt ccx, &@ast::lit lit) -> ty::t {

trunk/src/lib/ivec.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import option::none;
44
import option::some;
5+
import uint::next_power_of_two;
56

67
type operator2[T,U,V] = fn(&T, &U) -> V;
78

@@ -110,7 +111,7 @@ fn slice_mut[T](&T[mutable?] v, uint start, uint end) -> T[mutable] {
110111

111112
/// Expands the given vector in-place by appending `n` copies of `initval`.
112113
fn grow[T](&mutable T[] v, uint n, &T initval) {
113-
reserve(v, len(v) + n);
114+
reserve(v, next_power_of_two(len(v) + n));
114115
let uint i = 0u;
115116
while (i < n) {
116117
v += ~[initval];
@@ -120,7 +121,7 @@ fn grow[T](&mutable T[] v, uint n, &T initval) {
120121

121122
// TODO: Remove me once we have slots.
122123
fn grow_mut[T](&mutable T[mutable] v, uint n, &T initval) {
123-
reserve(v, len(v) + n);
124+
reserve(v, next_power_of_two(len(v) + n));
124125
let uint i = 0u;
125126
while (i < n) {
126127
v += ~[mutable initval];
@@ -131,7 +132,7 @@ fn grow_mut[T](&mutable T[mutable] v, uint n, &T initval) {
131132
/// Calls `f` `n` times and appends the results of these calls to the given
132133
/// vector.
133134
fn grow_fn[T](&mutable T[] v, uint n, fn(uint)->T init_fn) {
134-
reserve(v, len(v) + n);
135+
reserve(v, next_power_of_two(len(v) + n));
135136
let uint i = 0u;
136137
while (i < n) {
137138
v += ~[init_fn(i)];

trunk/src/lib/smallintmap.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
import option::none;
66
import option::some;
77

8-
type smallintmap[T] = rec(mutable vec[mutable option::t[T]] v);
8+
// FIXME: Should not be @; there's a bug somewhere in rustc that requires this
9+
// to be.
10+
type smallintmap[T] = @rec(mutable (option::t[T])[mutable] v);
911

1012
fn mk[T]() -> smallintmap[T] {
11-
let vec[mutable option::t[T]] v = [mutable ];
12-
ret rec(mutable v=v);
13+
let (option::t[T])[mutable] v = ~[mutable];
14+
ret @rec(mutable v=v);
1315
}
1416

1517
fn insert[T](&smallintmap[T] m, uint key, &T val) {
16-
vec::grow_set[option::t[T]](m.v, key, none[T], some[T](val));
18+
ivec::grow_set[option::t[T]](m.v, key, none[T], some[T](val));
1719
}
1820

1921
fn find[T](&smallintmap[T] m, uint key) -> option::t[T] {
20-
if (key < vec::len[option::t[T]](m.v)) { ret m.v.(key); }
22+
if (key < ivec::len[option::t[T]](m.v)) { ret m.v.(key); }
2123
ret none[T];
2224
}
2325

@@ -36,7 +38,8 @@ fn contains_key[T](&smallintmap[T] m, uint key) -> bool {
3638
}
3739

3840
fn truncate[T](&smallintmap[T] m, uint len) {
39-
m.v = vec::slice_mut[option::t[T]](m.v, 0u, len);
41+
m.v = ivec::slice_mut[option::t[T]](m.v, 0u, len);
4042
}
4143

42-
fn max_key[T](&smallintmap[T] m) -> uint { ret vec::len[option::t[T]](m.v); }
44+
fn max_key[T](&smallintmap[T] m) -> uint { ret ivec::len[option::t[T]](m.v); }
45+

0 commit comments

Comments
 (0)