diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-11-07 18:10:00 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-11-07 18:10:00 -0500 |
commit | c2b05499ffa82cfadc668e140b8f96ab43b1c715 (patch) | |
tree | 696f234835b7758bbb6f6b528d6bdbef1f6193e5 /klm/util/murmur_hash.cc | |
parent | bcda3258ab35cba2f71e28e1c93863958f5aca8b (diff) | |
parent | bdd7fe7b513ade0b979fc050766e375044e84e86 (diff) |
Merge branch 'master' of github.com:redpony/cdec
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 |