Mop up workarounds in stdlib no longer required as issue #93 is closed.

This commit is contained in:
Graydon Hoare 2010-08-05 10:10:39 -07:00
parent 29987b56e1
commit 935b4347e2
3 changed files with 11 additions and 24 deletions

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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]();