Skip to content
Snippets Groups Projects
Commit 79032acf authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Add support to LLUUID and LLMaterialID for robinhood

parent 6aab1e5e
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment