diff options
author | Patrick Simianer <p@simianer.de> | 2011-11-13 12:26:23 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2011-11-13 12:26:23 +0100 |
commit | bf5dd9905851113f5ebb38f207b6218c37a4f113 (patch) | |
tree | 2976abc442418dda2f27720377a65a4626fa9914 /klm/util/murmur_hash.cc | |
parent | a6f3fb188e539eb1eb4d9e0be9fffdf15bdf9170 (diff) | |
parent | 105a52a8d37497fe69a01a7de771ef9b9300cd71 (diff) |
merge upstream/master
Diffstat (limited to 'klm/util/murmur_hash.cc')
-rw-r--r-- | klm/util/murmur_hash.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/klm/util/murmur_hash.cc b/klm/util/murmur_hash.cc index fec47fd9..ef5783fe 100644 --- a/klm/util/murmur_hash.cc +++ b/klm/util/murmur_hash.cc @@ -117,13 +117,18 @@ uint64_t MurmurHash64B ( const void * key, std::size_t len, unsigned int seed ) return h; } +// Trick to test for 64-bit architecture at compile time. +namespace { +template <unsigned L> uint64_t MurmurHashNativeBackend(const void * key, std::size_t len, unsigned int seed) { + return MurmurHash64A(key, len, seed); +} +template <> uint64_t MurmurHashNativeBackend<4>(const void * key, std::size_t len, unsigned int seed) { + return MurmurHash64B(key, len, seed); +} +} // namespace uint64_t MurmurHashNative(const void * key, std::size_t len, unsigned int seed) { - if (sizeof(int) == 4) { - return MurmurHash64B(key, len, seed); - } else { - return MurmurHash64A(key, len, seed); - } + return MurmurHashNativeBackend<sizeof(void*)>(key, len, seed); } } // namespace util |