summaryrefslogtreecommitdiffstats
path: root/base/containers
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-26 19:39:11 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-26 19:39:11 +0000
commit51421855d70a15031f7046efd771db6d6f453415 (patch)
tree1ba8c87e3b72d88162cfb691c337da36ce2d7a0d /base/containers
parent4cb23c1b551528aa99b7b8c36841cba21f1f5219 (diff)
downloadchromium_src-51421855d70a15031f7046efd771db6d6f453415.zip
chromium_src-51421855d70a15031f7046efd771db6d6f453415.tar.gz
chromium_src-51421855d70a15031f7046efd771db6d6f453415.tar.bz2
Shift by the right number of bytes when grabbing the high 32 bits.
When size_t is not 64 bits (8 bytes) but instead N < 8 bytes, we want to grab the top N bytes from the 64-bit result. This code was meant to do this: hash64 >> (sizeof(uint64) - sizeof(std::size_t)) But this translates to: hash64 >> (8 - N) And 8-N is the number of bytes we want to shift, not the number of bits, where as operator>> excepts a number of bits. Fix this to correct the algorithm for platforms with small size_t. R=ajwong BUG= Review URL: https://codereview.chromium.org/156103003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/containers')
-rw-r--r--base/containers/hash_tables.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/base/containers/hash_tables.h b/base/containers/hash_tables.h
index 365b586..6f37c49 100644
--- a/base/containers/hash_tables.h
+++ b/base/containers/hash_tables.h
@@ -140,7 +140,7 @@ inline std::size_t HashInts32(uint32 value1, uint32 value2) {
hash64 = hash64 * odd_random + shift_random;
std::size_t high_bits = static_cast<std::size_t>(
- hash64 >> (sizeof(uint64) - sizeof(std::size_t)));
+ hash64 >> (8 * (sizeof(uint64) - sizeof(std::size_t))));
return high_bits;
}
@@ -175,7 +175,7 @@ inline std::size_t HashInts64(uint64 value1, uint64 value2) {
hash64 = hash64 * odd_random + shift_random;
std::size_t high_bits = static_cast<std::size_t>(
- hash64 >> (sizeof(uint64) - sizeof(std::size_t)));
+ hash64 >> (8 * (sizeof(uint64) - sizeof(std::size_t))));
return high_bits;
}