[tint][utils] Simplify pointer hashing
Change-Id: Ia6e46ccb81419ed9f4ef99aaeb1aef5c60a82e1a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/172021
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/utils/math/hash.h b/src/tint/utils/math/hash.h
index e143d07..43c97f4 100644
--- a/src/tint/utils/math/hash.h
+++ b/src/tint/utils/math/hash.h
@@ -122,11 +122,11 @@
/// @param ptr the pointer to hash
/// @returns a hash of the pointer
size_t operator()(T* ptr) const {
- auto hash = std::hash<T*>()(ptr);
+ auto hash = static_cast<size_t>(reinterpret_cast<uintptr_t>(ptr));
#ifdef TINT_HASH_SEED
hash ^= static_cast<uint32_t>(TINT_HASH_SEED);
#endif
- return hash ^ (hash >> 4);
+ return hash >> 4;
}
};