summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2020-10-08 13:19:51 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2020-10-08 13:20:51 +0000
commit8a6cd15d44c72c8c36a79939906ecaea0eb266c7 (patch)
treefa2560218cc65563526ade3c8e3716c8a685aa53 /vespalib
parent312694ad6aee3b31f2061b6742b2fb6a8be51a59 (diff)
Use XXH3 over XXH64 as vespalib string hash function
XXH3 is faster than XXH64 across the board, especially for short inputs. Change around some tests that implicitly depended on the old hashing.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/stllike/hash_test.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hash_fun.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp
index d6f5c2ba65d..2b190b6b2dc 100644
--- a/vespalib/src/tests/stllike/hash_test.cpp
+++ b/vespalib/src/tests/stllike/hash_test.cpp
@@ -33,7 +33,7 @@ namespace {
TEST("test that hashValue gives expected response")
{
const char * s("abcdefghi");
- EXPECT_EQUAL(2878261200250560019ul, vespalib::hashValue(s));
+ EXPECT_EQUAL(16203358805722239136ul, vespalib::hashValue(s));
EXPECT_EQUAL(vespalib::hashValue(s), vespalib::hashValue(s, strlen(s)));
EXPECT_NOT_EQUAL(vespalib::hashValue(s), vespalib::hashValue(s, strlen(s)-1));
}
diff --git a/vespalib/src/vespa/vespalib/stllike/hash_fun.cpp b/vespalib/src/vespa/vespalib/stllike/hash_fun.cpp
index f057a229098..8e1d6061ff0 100644
--- a/vespalib/src/vespa/vespalib/stllike/hash_fun.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/hash_fun.cpp
@@ -22,7 +22,7 @@ hashValue(const char *str) noexcept
size_t
hashValue(const void * buf, size_t sz) noexcept
{
- return XXH64(buf, sz, 0);
+ return XXH3_64bits(buf, sz);
}
}