]> git.lizzy.rs Git - rust.git/commitdiff
core: fix trie chunk function
authorGraydon Hoare <graydon@mozilla.com>
Wed, 6 Mar 2013 04:54:19 +0000 (20:54 -0800)
committerDaniel Micay <danielmicay@gmail.com>
Sat, 16 Mar 2013 01:12:17 +0000 (21:12 -0400)
src/libcore/trie.rs

index d6dcad334085da1ad255fb58f9c6e970ef1d328f..cf34ba774a85f049568a8654bda99808460f53c1 100644 (file)
@@ -272,8 +272,8 @@ fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool {
 // if this was done via a trait, the key could be generic
 #[inline(always)]
 pure fn chunk(n: uint, idx: uint) -> uint {
-    let real_idx = uint::bytes - 1 - idx;
-    (n >> (SHIFT * real_idx)) & MASK
+    let sh = uint::bits - (SHIFT * (idx + 1));
+    (n >> sh) & MASK
 }
 
 fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,