From 935b4347e286b0022ae6f38b2875df6f05c55fa3 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 5 Aug 2010 10:10:39 -0700 Subject: [PATCH] Mop up workarounds in stdlib no longer required as issue #93 is closed. --- src/lib/_str.rs | 5 ++--- src/lib/deque.rs | 18 ++++++------------ src/lib/map.rs | 12 +++--------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/lib/_str.rs b/src/lib/_str.rs index 8eed9a38466..7d1a2dbdcd7 100644 --- a/src/lib/_str.rs +++ b/src/lib/_str.rs @@ -16,8 +16,7 @@ fn is_ascii(str s) -> bool { let uint i = len(s); while (i > 0u) { i -= 1u; - // FIXME (issue #94) - if ((s.(i as int) & 0x80u8) != 0u8) { + if ((s.(i) & 0x80u8) != 0u8) { ret false; } } @@ -38,7 +37,7 @@ fn buf(str s) -> sbuf { fn bytes(&str s) -> vec[u8] { fn ith(str s, uint i) -> u8 { - ret s.(i as int); // FIXME (issue #94) + ret s.(i); } ret _vec.init_fn[u8](bind ith(s, _), _str.len(s)); } diff --git a/src/lib/deque.rs b/src/lib/deque.rs index bd42d7cb2dc..bf7acb533bb 100644 --- a/src/lib/deque.rs +++ b/src/lib/deque.rs @@ -36,7 +36,7 @@ fn create[T]() -> t[T] { fn fill[T](uint i, uint nelts, uint lo, &vec[cell[T]] old) -> cell[T] { if (i < nelts) { - ret old.(((lo + i) % nelts) as int); + ret old.((lo + i) % nelts); } else { ret util.none[T](); } @@ -47,14 +47,8 @@ fn create[T]() -> t[T] { ret _vec.init_fn[cell[T]](copy_op, nalloc); } - /** - * FIXME (issue #94): We're converting to int every time we index into the - * vec, but we really want to index with the lo and hi uints that we have - * around. - */ - fn get[T](&vec[cell[T]] elts, uint i) -> T { - alt (elts.(i as int)) { + alt (elts.(i)) { case (util.some[T](t)) { ret t; } case (_) { fail; } } @@ -82,7 +76,7 @@ fn create[T]() -> t[T] { hi = nelts; } - elts.(lo as int) = util.some[T](t); + elts.(lo) = util.some[T](t); nelts += 1u; } @@ -93,7 +87,7 @@ fn create[T]() -> t[T] { hi = nelts; } - elts.(hi as int) = util.some[T](t); + elts.(hi) = util.some[T](t); hi = (hi + 1u) % _vec.len[cell[T]](elts); nelts += 1u; } @@ -104,7 +98,7 @@ fn create[T]() -> t[T] { */ fn pop_front() -> T { let T t = get[T](elts, lo); - elts.(lo as int) = util.none[T](); + elts.(lo) = util.none[T](); lo = (lo + 1u) % _vec.len[cell[T]](elts); ret t; } @@ -117,7 +111,7 @@ fn create[T]() -> t[T] { } let T t = get[T](elts, hi); - elts.(hi as int) = util.none[T](); + elts.(hi) = util.none[T](); ret t; } diff --git a/src/lib/map.rs b/src/lib/map.rs index f95741761c0..ff7b441115b 100644 --- a/src/lib/map.rs +++ b/src/lib/map.rs @@ -75,8 +75,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { { let uint i = 0u; while (i < nbkts) { - // FIXME (issue #94): as in find_common() - let int j = (hash[K](hasher, nbkts, key, i)) as int; + let uint j = (hash[K](hasher, nbkts, key, i)); alt (bkts.(j)) { case (some[K, V](k, _)) { if (eqer(key, k)) { @@ -103,8 +102,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { { let uint i = 0u; while (i < nbkts) { - // FIXME (issue #94): Pending bugfix, remove uint coercion. - let int j = (hash[K](hasher, nbkts, key, i)) as int; + let uint j = (hash[K](hasher, nbkts, key, i)); alt (bkts.(j)) { case (some[K, V](k, v)) { if (eqer(key, k)) { @@ -149,9 +147,6 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { if (!util.rational_leq(load, lf)) { let uint nnewbkts = _int.next_power_of_two(nbkts + 1u); - // FIXME (issue #94): Enforce our workaround to issue #94. - check ((nnewbkts as int) > 0); - let vec[mutable bucket[K, V]] newbkts = make_buckets[K, V](nnewbkts); rehash[K, V](hasher, eqer, bkts, nbkts, newbkts, nnewbkts); } @@ -183,8 +178,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] { fn remove(&K key) -> util.option[V] { let uint i = 0u; while (i < nbkts) { - // FIXME (issue #94): as in find_common() - let int j = (hash[K](hasher, nbkts, key, i)) as int; + let uint j = (hash[K](hasher, nbkts, key, i)); alt (bkts.(j)) { case (some[K, V](_, val)) { bkts.(j) = deleted[K, V]();