about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-12-07 11:52:38 -0800
committerGraydon Hoare <graydon@mozilla.com>2011-12-07 11:52:38 -0800
commita3f48d3fe1d90a4684cb20e75688ffbca804e82c (patch)
treef8ca510a3e827cb31e38cffdc260ab6112cf6b79 /src/libstd
parent1652b921fa2fadc936b346fc3de217cf97b0e476 (diff)
parent6c95e400d82699887b66f5de0fef2bb5e1f8cc32 (diff)
downloadrust-a3f48d3fe1d90a4684cb20e75688ffbca804e82c.tar.gz
rust-a3f48d3fe1d90a4684cb20e75688ffbca804e82c.zip
Merge branch 'master' of github.com:graydon/rust
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/map.rs20
-rw-r--r--src/libstd/str.rs2
-rw-r--r--src/libstd/task.rs2
3 files changed, 14 insertions, 10 deletions
diff --git a/src/libstd/map.rs b/src/libstd/map.rs
index c802b5b889f..a4ef4674017 100644
--- a/src/libstd/map.rs
+++ b/src/libstd/map.rs
@@ -137,21 +137,25 @@ fn mk_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
     // is always a power of 2), so that all buckets are probed for a
     // fixed key.
 
-    fn hashl(n: uint, _nbkts: uint) -> uint { ret (n >>> 16u) * 2u + 1u; }
-    fn hashr(n: uint, _nbkts: uint) -> uint { ret 0x0000_ffff_u & n; }
-    fn hash(h: uint, nbkts: uint, i: uint) -> uint {
-        ret (hashl(h, nbkts) * i + hashr(h, nbkts)) % nbkts;
+    fn hashl(n: u32) -> u32 { ret (n >>> 16u32) * 2u32 + 1u32; }
+    fn hashr(n: u32) -> u32 { ret 0x0000_ffff_u32 & n; }
+    fn hash(h: u32, nbkts: uint, i: uint) -> uint {
+        ret ((hashl(h) as uint) * i + (hashr(h) as uint)) % nbkts;
     }
+
+    fn to_u64(h: uint) -> u32 {
+        ret (h as u32) ^ ((h >>> 16u) as u32);
+    }
+
     /**
      * We attempt to never call this with a full table.  If we do, it
      * will fail.
      */
-
     fn insert_common<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>,
                                      bkts: [mutable bucket<K, V>],
                                      nbkts: uint, key: K, val: V) -> bool {
         let i: uint = 0u;
-        let h: uint = hasher(key);
+        let h = to_u64(hasher(key));
         while i < nbkts {
             let j: uint = hash(h, nbkts, i);
             alt bkts[j] {
@@ -171,7 +175,7 @@ fn mk_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
                                    bkts: [mutable bucket<K, V>],
                                    nbkts: uint, key: K) -> option::t<V> {
         let i: uint = 0u;
-        let h: uint = hasher(key);
+        let h = to_u64(hasher(key));
         while i < nbkts {
             let j: uint = hash(h, nbkts, i);
             alt bkts[j] {
@@ -244,7 +248,7 @@ fn mk_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
         }
         fn remove(key: K) -> option::t<V> {
             let i: uint = 0u;
-            let h: uint = hasher(key);
+            let h = to_u64(hasher(key));
             while i < nbkts {
                 let j: uint = hash(h, nbkts, i);
                 alt bkts[j] {
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 2bae8d699a5..521dc33758e 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -324,7 +324,7 @@ fn char_range_at(s: str, i: uint) -> {ch: char, next: uint} {
     // Clunky way to get the right bits from the first byte. Uses two shifts,
     // the first to clip off the marker bits at the left of the byte, and then
     // a second (as uint) to get it to the right position.
-    val += (b0 << (w + 1u as u8) as uint) << (w - 1u) * 6u - w - 1u;
+    val += (b0 << (w + 1u as u8) as uint) << ((w - 1u) * 6u - w - 1u);
     ret {ch: val as char, next: i};
 }
 
diff --git a/src/libstd/task.rs b/src/libstd/task.rs
index a8765407f3a..3e396d3ac63 100644
--- a/src/libstd/task.rs
+++ b/src/libstd/task.rs
@@ -288,7 +288,7 @@ fn spawn_inner<send T>(-data: T, f: fn(T),
                           notify: option<comm::chan<task_notification>>)
     -> task unsafe {
 
-    fn wrapper<send T>(-data: *u8, f: fn(T)) unsafe {
+    fn wrapper<send T>(data: *u8, f: fn(T)) unsafe {
         let data: ~T = unsafe::reinterpret_cast(data);
         f(*data);
     }