diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/wtf/hash_map.h')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/wtf/hash_map.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/chromium/third_party/blink/renderer/platform/wtf/hash_map.h b/chromium/third_party/blink/renderer/platform/wtf/hash_map.h index 46b39e0697f..88fc20f0ea1 100644 --- a/chromium/third_party/blink/renderer/platform/wtf/hash_map.h +++ b/chromium/third_party/blink/renderer/platform/wtf/hash_map.h @@ -22,6 +22,7 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_HASH_MAP_H_ #include <initializer_list> +#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/partition_allocator.h" #include "third_party/blink/renderer/platform/wtf/construct_traits.h" #include "third_party/blink/renderer/platform/wtf/hash_table.h" @@ -43,6 +44,12 @@ struct KeyValuePairKeyExtractor { static const typename T::KeyType& Extract(const T& p) { return p.key; } + // Assumes out points to a buffer of size at least sizeof(T::KeyType). + template <typename T> + static const typename T::KeyType& ExtractSafe(const T& p, void* out) { + AtomicReadMemcpy<sizeof(typename T::KeyType)>(out, &p.key); + return *reinterpret_cast<typename T::KeyType*>(out); + } }; // Note: empty or deleted key values are not allowed, using them may lead to @@ -202,7 +209,8 @@ class HashMap { static bool IsValidKey(const IncomingKeyType&); template <typename VisitorDispatcher, typename A = Allocator> - std::enable_if_t<A::kIsGarbageCollected> Trace(VisitorDispatcher visitor) { + std::enable_if_t<A::kIsGarbageCollected> Trace( + VisitorDispatcher visitor) const { impl_.Trace(visitor); } |