From 0cdeb682af87a0703f8650e013e4685af0633f3f Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Tue, 29 May 2018 12:43:33 +0200 Subject: [PATCH] common/performance: improved hash calculation for hobject_t and ghobject_t Signed-off-by: Adam Kupczyk --- src/common/hobject.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/hobject.h b/src/common/hobject.h index 03abd4bd55173..c2d2c6b31863b 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -300,8 +300,13 @@ WRITE_CLASS_ENCODER(hobject_t) namespace std { template<> struct hash { size_t operator()(const hobject_t &r) const { - static rjhash I; - return r.get_hash() ^ I(r.snap); + static std::hash H; + static rjhash RJ; + size_t hash; + hash = H(r.oid); + hash = RJ(hash ^ r.get_hash()); + hash = RJ(hash ^ r.snap); + return hash; } }; } // namespace std @@ -473,8 +478,12 @@ WRITE_CLASS_ENCODER(ghobject_t) namespace std { template<> struct hash { size_t operator()(const ghobject_t &r) const { - static rjhash I; - return r.hobj.get_hash() ^ I(r.hobj.snap); + static rjhash RJ; + static hash HO; + size_t hash = HO(r.hobj); + hash = RJ(hash ^ r.generation); + hash = hash ^ r.shard_id.id; + return hash; } }; } // namespace std -- 2.39.5