summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2023-09-11 11:51:20 -0500
committerRunitaiLinden <davep@lindenlab.com>2023-09-11 11:51:20 -0500
commit74940194fa5cd4c5182f141ef262e5568156bdce (patch)
tree8d3a8e779d34a94b4df3dc4517dfa598b4b98367 /indra/llprimitive
parente3e1d42ab3021cf6e6ac68fff54c9185fd3a0ad1 (diff)
parent0b02bf5d262fe9a6de968686420c4d525ac04077 (diff)
Merge remote-tracking branch 'remotes/origin/DRTVWR-559' into davep/SL-19842
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/llmaterialid.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h
index e6165dfc91..5eb463b0fd 100644
--- a/indra/llprimitive/llmaterialid.h
+++ b/indra/llprimitive/llmaterialid.h
@@ -67,6 +67,14 @@ public:
static const LLMaterialID null;
+ // Returns a 64 bits digest of the material Id, by XORing its two 64 bits
+ // long words. HB
+ inline U64 getDigest64() const
+ {
+ U64* tmp = (U64*)mID;
+ return tmp[0] ^ tmp[1];
+ }
+
private:
void parseFromBinary(const LLSD::Binary& pMaterialID);
void copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID);
@@ -75,5 +83,23 @@ private:
U8 mID[MATERIAL_ID_SIZE];
} ;
+// std::hash implementation for LLMaterialID
+namespace std
+{
+ template<> struct hash<LLMaterialID>
+ {
+ inline size_t operator()(const LLMaterialID& id) const noexcept
+ {
+ return (size_t)id.getDigest64();
+ }
+ };
+}
+
+// For use with boost containers.
+inline size_t hash_value(const LLMaterialID& id) noexcept
+{
+ return (size_t)id.getDigest64();
+}
+
#endif // LL_LLMATERIALID_H