diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h index 69894a4b53e7a685f7e838d94a4930b7cf9caa67..8acfca950467cd28cf8fb04869eabb7547d3e57b 100644 --- a/indra/llcommon/lluuid.h +++ b/indra/llcommon/lluuid.h @@ -35,6 +35,8 @@ #include "llpreprocessor.h" #include <immintrin.h> +#include <robin_hood.h> + class LLMutex; const S32 UUID_BYTES = 16; @@ -177,15 +179,7 @@ class LL_COMMON_API LLUUID inline size_t hash() const { - size_t seed = 0; - for (U8 i = 0; i < 4; ++i) - { - seed ^= static_cast<size_t>(mData[i * 4]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast<size_t>(mData[i * 4 + 1]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast<size_t>(mData[i * 4 + 2]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - seed ^= static_cast<size_t>(mData[i * 4 + 3]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } - return seed; + return robin_hood::hash_bytes(mData, UUID_BYTES); } // END BOOST @@ -271,6 +265,16 @@ namespace boost { }; } +namespace robin_hood { + template<> struct hash<LLUUID> + { + size_t operator()(const LLUUID& id) const + { + return id.hash(); + } + }; +} + /* * Sub-classes for keeping transaction IDs and asset IDs * straight. diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h index 549f723352cfac5a755508fc847c4328b3414996..2b3640e79ada9fc606b189e222e6b7447c70d173 100644 --- a/indra/llprimitive/llmaterialid.h +++ b/indra/llprimitive/llmaterialid.h @@ -33,6 +33,8 @@ #include <immintrin.h> #include "llsd.h" +#include <robin_hood.h> + class LLMaterialID { public: @@ -147,7 +149,7 @@ class LLMaterialID seed ^= static_cast<size_t>(mID[i * 4 + 2]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); seed ^= static_cast<size_t>(mID[i * 4 + 3]) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } - return seed; + return robin_hood::hash_bytes(mID, MATERIAL_ID_SIZE); } // END BOOST @@ -168,5 +170,35 @@ class LLMaterialID U8 mID[MATERIAL_ID_SIZE] = {}; } ; +namespace std { + template <> struct hash<LLMaterialID> + { + size_t operator()(const LLMaterialID& id) const + { + return id.hash(); + } + }; +} + +namespace boost { + template<> struct hash<LLMaterialID> + { + size_t operator()(const LLMaterialID& id) const + { + return id.hash(); + } + }; +} + +namespace robin_hood { + template<> struct hash<LLMaterialID> + { + size_t operator()(const LLMaterialID& id) const + { + return id.hash(); + } + }; +} + #endif // LL_LLMATERIALID_H