Skip to content

Commit 935b434

Browse files
committed
Mop up workarounds in stdlib no longer required as issue rust-lang#93 is closed.
1 parent 29987b5 commit 935b434

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

Diff for: src/lib/_str.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ fn is_ascii(str s) -> bool {
1616
let uint i = len(s);
1717
while (i > 0u) {
1818
i -= 1u;
19-
// FIXME (issue #94)
20-
if ((s.(i as int) & 0x80u8) != 0u8) {
19+
if ((s.(i) & 0x80u8) != 0u8) {
2120
ret false;
2221
}
2322
}
@@ -38,7 +37,7 @@ fn buf(str s) -> sbuf {
3837

3938
fn bytes(&str s) -> vec[u8] {
4039
fn ith(str s, uint i) -> u8 {
41-
ret s.(i as int); // FIXME (issue #94)
40+
ret s.(i);
4241
}
4342
ret _vec.init_fn[u8](bind ith(s, _), _str.len(s));
4443
}

Diff for: src/lib/deque.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn create[T]() -> t[T] {
3636

3737
fn fill[T](uint i, uint nelts, uint lo, &vec[cell[T]] old) -> cell[T] {
3838
if (i < nelts) {
39-
ret old.(((lo + i) % nelts) as int);
39+
ret old.((lo + i) % nelts);
4040
} else {
4141
ret util.none[T]();
4242
}
@@ -47,14 +47,8 @@ fn create[T]() -> t[T] {
4747
ret _vec.init_fn[cell[T]](copy_op, nalloc);
4848
}
4949

50-
/**
51-
* FIXME (issue #94): We're converting to int every time we index into the
52-
* vec, but we really want to index with the lo and hi uints that we have
53-
* around.
54-
*/
55-
5650
fn get[T](&vec[cell[T]] elts, uint i) -> T {
57-
alt (elts.(i as int)) {
51+
alt (elts.(i)) {
5852
case (util.some[T](t)) { ret t; }
5953
case (_) { fail; }
6054
}
@@ -82,7 +76,7 @@ fn create[T]() -> t[T] {
8276
hi = nelts;
8377
}
8478

85-
elts.(lo as int) = util.some[T](t);
79+
elts.(lo) = util.some[T](t);
8680
nelts += 1u;
8781
}
8882

@@ -93,7 +87,7 @@ fn create[T]() -> t[T] {
9387
hi = nelts;
9488
}
9589

96-
elts.(hi as int) = util.some[T](t);
90+
elts.(hi) = util.some[T](t);
9791
hi = (hi + 1u) % _vec.len[cell[T]](elts);
9892
nelts += 1u;
9993
}
@@ -104,7 +98,7 @@ fn create[T]() -> t[T] {
10498
*/
10599
fn pop_front() -> T {
106100
let T t = get[T](elts, lo);
107-
elts.(lo as int) = util.none[T]();
101+
elts.(lo) = util.none[T]();
108102
lo = (lo + 1u) % _vec.len[cell[T]](elts);
109103
ret t;
110104
}
@@ -117,7 +111,7 @@ fn create[T]() -> t[T] {
117111
}
118112

119113
let T t = get[T](elts, hi);
120-
elts.(hi as int) = util.none[T]();
114+
elts.(hi) = util.none[T]();
121115
ret t;
122116
}
123117

Diff for: src/lib/map.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
7575
{
7676
let uint i = 0u;
7777
while (i < nbkts) {
78-
// FIXME (issue #94): as in find_common()
79-
let int j = (hash[K](hasher, nbkts, key, i)) as int;
78+
let uint j = (hash[K](hasher, nbkts, key, i));
8079
alt (bkts.(j)) {
8180
case (some[K, V](k, _)) {
8281
if (eqer(key, k)) {
@@ -103,8 +102,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
103102
{
104103
let uint i = 0u;
105104
while (i < nbkts) {
106-
// FIXME (issue #94): Pending bugfix, remove uint coercion.
107-
let int j = (hash[K](hasher, nbkts, key, i)) as int;
105+
let uint j = (hash[K](hasher, nbkts, key, i));
108106
alt (bkts.(j)) {
109107
case (some[K, V](k, v)) {
110108
if (eqer(key, k)) {
@@ -149,9 +147,6 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
149147
if (!util.rational_leq(load, lf)) {
150148
let uint nnewbkts = _int.next_power_of_two(nbkts + 1u);
151149

152-
// FIXME (issue #94): Enforce our workaround to issue #94.
153-
check ((nnewbkts as int) > 0);
154-
155150
let vec[mutable bucket[K, V]] newbkts = make_buckets[K, V](nnewbkts);
156151
rehash[K, V](hasher, eqer, bkts, nbkts, newbkts, nnewbkts);
157152
}
@@ -183,8 +178,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
183178
fn remove(&K key) -> util.option[V] {
184179
let uint i = 0u;
185180
while (i < nbkts) {
186-
// FIXME (issue #94): as in find_common()
187-
let int j = (hash[K](hasher, nbkts, key, i)) as int;
181+
let uint j = (hash[K](hasher, nbkts, key, i));
188182
alt (bkts.(j)) {
189183
case (some[K, V](_, val)) {
190184
bkts.(j) = deleted[K, V]();

0 commit comments

Comments
 (0)