/work/obj-fuzz/dist/include/nsHashKeys.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef nsTHashKeys_h__ |
8 | | #define nsTHashKeys_h__ |
9 | | |
10 | | #include "nsID.h" |
11 | | #include "nsISupports.h" |
12 | | #include "nsIHashable.h" |
13 | | #include "nsAutoPtr.h" |
14 | | #include "nsCOMPtr.h" |
15 | | #include "PLDHashTable.h" |
16 | | #include <new> |
17 | | |
18 | | #include "nsString.h" |
19 | | #include "nsCRTGlue.h" |
20 | | #include "nsUnicharUtils.h" |
21 | | #include "nsPointerHashKeys.h" |
22 | | |
23 | | #include <stdint.h> |
24 | | #include <stdlib.h> |
25 | | #include <string.h> |
26 | | |
27 | | #include <utility> |
28 | | |
29 | | #include "mozilla/HashFunctions.h" |
30 | | |
31 | | namespace mozilla { |
32 | | |
33 | | // These are defined analogously to the HashString overloads in mfbt. |
34 | | |
35 | | inline uint32_t |
36 | | HashString(const nsAString& aStr) |
37 | | { |
38 | | return HashString(aStr.BeginReading(), aStr.Length()); |
39 | | } |
40 | | |
41 | | inline uint32_t |
42 | | HashString(const nsACString& aStr) |
43 | 2.82M | { |
44 | 2.82M | return HashString(aStr.BeginReading(), aStr.Length()); |
45 | 2.82M | } |
46 | | |
47 | | } // namespace mozilla |
48 | | |
49 | | /** @file nsHashKeys.h |
50 | | * standard HashKey classes for nsBaseHashtable and relatives. Each of these |
51 | | * classes follows the nsTHashtable::EntryType specification |
52 | | * |
53 | | * Lightweight keytypes provided here: |
54 | | * nsStringHashKey |
55 | | * nsCStringHashKey |
56 | | * nsUint32HashKey |
57 | | * nsUint64HashKey |
58 | | * nsFloatHashKey |
59 | | * IntPtrHashKey |
60 | | * nsPtrHashKey |
61 | | * nsClearingPtrHashKey |
62 | | * nsVoidPtrHashKey |
63 | | * nsClearingVoidPtrHashKey |
64 | | * nsISupportsHashKey |
65 | | * nsIDHashKey |
66 | | * nsDepCharHashKey |
67 | | * nsCharPtrHashKey |
68 | | * nsUnicharPtrHashKey |
69 | | * nsHashableHashKey |
70 | | * nsGenericHashKey |
71 | | */ |
72 | | |
73 | | /** |
74 | | * hashkey wrapper using nsAString KeyType |
75 | | * |
76 | | * @see nsTHashtable::EntryType for specification |
77 | | */ |
78 | | class nsStringHashKey : public PLDHashEntryHdr |
79 | | { |
80 | | public: |
81 | | typedef const nsAString& KeyType; |
82 | | typedef const nsAString* KeyTypePointer; |
83 | | |
84 | | explicit nsStringHashKey(KeyTypePointer aStr) : mStr(*aStr) {} |
85 | | nsStringHashKey(const nsStringHashKey&) = delete; |
86 | | nsStringHashKey(nsStringHashKey&& aToMove) |
87 | | : PLDHashEntryHdr(std::move(aToMove)) |
88 | | , mStr(std::move(aToMove.mStr)) |
89 | 0 | {} |
90 | | ~nsStringHashKey() {} |
91 | | |
92 | | KeyType GetKey() const { return mStr; } |
93 | | bool KeyEquals(const KeyTypePointer aKey) const |
94 | | { |
95 | | return mStr.Equals(*aKey); |
96 | | } |
97 | | |
98 | | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
99 | | static PLDHashNumber HashKey(const KeyTypePointer aKey) |
100 | | { |
101 | | return mozilla::HashString(*aKey); |
102 | | } |
103 | | |
104 | | #ifdef MOZILLA_INTERNAL_API |
105 | | // To avoid double-counting, only measure the string if it is unshared. |
106 | | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
107 | 0 | { |
108 | 0 | return GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf); |
109 | 0 | } |
110 | | #endif |
111 | | |
112 | | enum { ALLOW_MEMMOVE = true }; |
113 | | |
114 | | private: |
115 | | nsString mStr; |
116 | | }; |
117 | | |
118 | | #ifdef MOZILLA_INTERNAL_API |
119 | | |
120 | | /** |
121 | | * hashkey wrapper using nsAString KeyType |
122 | | * |
123 | | * This is internal-API only because nsCaseInsensitiveStringComparator is |
124 | | * internal-only. |
125 | | * |
126 | | * @see nsTHashtable::EntryType for specification |
127 | | */ |
128 | | class nsStringCaseInsensitiveHashKey : public PLDHashEntryHdr |
129 | | { |
130 | | public: |
131 | | typedef const nsAString& KeyType; |
132 | | typedef const nsAString* KeyTypePointer; |
133 | | |
134 | | explicit nsStringCaseInsensitiveHashKey(KeyTypePointer aStr) |
135 | | : mStr(*aStr) |
136 | 0 | { |
137 | 0 | // take it easy just deal HashKey |
138 | 0 | } |
139 | | |
140 | | nsStringCaseInsensitiveHashKey(const nsStringCaseInsensitiveHashKey&) = delete; |
141 | | nsStringCaseInsensitiveHashKey(nsStringCaseInsensitiveHashKey&& aToMove) |
142 | | : PLDHashEntryHdr(std::move(aToMove)) |
143 | | , mStr(std::move(aToMove.mStr)) |
144 | 0 | { |
145 | 0 | } |
146 | 0 | ~nsStringCaseInsensitiveHashKey() {} |
147 | | |
148 | 0 | KeyType GetKey() const { return mStr; } |
149 | | bool KeyEquals(const KeyTypePointer aKey) const |
150 | 0 | { |
151 | 0 | return mStr.Equals(*aKey, nsCaseInsensitiveStringComparator()); |
152 | 0 | } |
153 | | |
154 | 0 | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
155 | | static PLDHashNumber HashKey(const KeyTypePointer aKey) |
156 | 0 | { |
157 | 0 | nsAutoString tmKey(*aKey); |
158 | 0 | ToLowerCase(tmKey); |
159 | 0 | return mozilla::HashString(tmKey); |
160 | 0 | } |
161 | | enum { ALLOW_MEMMOVE = true }; |
162 | | |
163 | | // To avoid double-counting, only measure the string if it is unshared. |
164 | | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
165 | 0 | { |
166 | 0 | return GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf); |
167 | 0 | } |
168 | | |
169 | | private: |
170 | | const nsString mStr; |
171 | | }; |
172 | | |
173 | | #endif |
174 | | |
175 | | /** |
176 | | * hashkey wrapper using nsACString KeyType |
177 | | * |
178 | | * @see nsTHashtable::EntryType for specification |
179 | | */ |
180 | | class nsCStringHashKey : public PLDHashEntryHdr |
181 | | { |
182 | | public: |
183 | | typedef const nsACString& KeyType; |
184 | | typedef const nsACString* KeyTypePointer; |
185 | | |
186 | 3.82k | explicit nsCStringHashKey(const nsACString* aStr) : mStr(*aStr) {} |
187 | | nsCStringHashKey(nsCStringHashKey&& aOther) |
188 | | : PLDHashEntryHdr(std::move(aOther)) |
189 | | , mStr(std::move(aOther.mStr)) |
190 | 0 | {} |
191 | 4 | ~nsCStringHashKey() {} |
192 | | |
193 | 0 | KeyType GetKey() const { return mStr; } |
194 | 2.52M | bool KeyEquals(KeyTypePointer aKey) const { return mStr.Equals(*aKey); } |
195 | | |
196 | 2.82M | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
197 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
198 | 2.82M | { |
199 | 2.82M | return mozilla::HashString(*aKey); |
200 | 2.82M | } |
201 | | |
202 | | #ifdef MOZILLA_INTERNAL_API |
203 | | // To avoid double-counting, only measure the string if it is unshared. |
204 | | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
205 | 0 | { |
206 | 0 | return GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf); |
207 | 0 | } |
208 | | #endif |
209 | | |
210 | | enum { ALLOW_MEMMOVE = true }; |
211 | | |
212 | | private: |
213 | | const nsCString mStr; |
214 | | }; |
215 | | |
216 | | /** |
217 | | * hashkey wrapper using uint32_t KeyType |
218 | | * |
219 | | * @see nsTHashtable::EntryType for specification |
220 | | */ |
221 | | class nsUint32HashKey : public PLDHashEntryHdr |
222 | | { |
223 | | public: |
224 | | typedef const uint32_t& KeyType; |
225 | | typedef const uint32_t* KeyTypePointer; |
226 | | |
227 | | explicit nsUint32HashKey(KeyTypePointer aKey) : mValue(*aKey) {} |
228 | | nsUint32HashKey(nsUint32HashKey&& aOther) |
229 | | : PLDHashEntryHdr(std::move(aOther)) |
230 | | , mValue(std::move(aOther.mValue)) |
231 | 0 | {} |
232 | | ~nsUint32HashKey() {} |
233 | | |
234 | 0 | KeyType GetKey() const { return mValue; } |
235 | | bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; } |
236 | | |
237 | | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
238 | | static PLDHashNumber HashKey(KeyTypePointer aKey) { return *aKey; } |
239 | | enum { ALLOW_MEMMOVE = true }; |
240 | | |
241 | | private: |
242 | | const uint32_t mValue; |
243 | | }; |
244 | | |
245 | | /** |
246 | | * hashkey wrapper using uint64_t KeyType |
247 | | * |
248 | | * @see nsTHashtable::EntryType for specification |
249 | | */ |
250 | | class nsUint64HashKey : public PLDHashEntryHdr |
251 | | { |
252 | | public: |
253 | | typedef const uint64_t& KeyType; |
254 | | typedef const uint64_t* KeyTypePointer; |
255 | | |
256 | 3 | explicit nsUint64HashKey(KeyTypePointer aKey) : mValue(*aKey) {} |
257 | | nsUint64HashKey(nsUint64HashKey&& aOther) |
258 | | : PLDHashEntryHdr(std::move(aOther)) |
259 | | , mValue(std::move(aOther.mValue)) |
260 | 0 | {} |
261 | 0 | ~nsUint64HashKey() {} |
262 | | |
263 | 0 | KeyType GetKey() const { return mValue; } |
264 | 0 | bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; } |
265 | | |
266 | 3 | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
267 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
268 | 3 | { |
269 | 3 | return PLDHashNumber(*aKey); |
270 | 3 | } |
271 | | enum { ALLOW_MEMMOVE = true }; |
272 | | |
273 | | private: |
274 | | const uint64_t mValue; |
275 | | }; |
276 | | |
277 | | /** |
278 | | * hashkey wrapper using float KeyType |
279 | | * |
280 | | * @see nsTHashtable::EntryType for specification |
281 | | */ |
282 | | class nsFloatHashKey : public PLDHashEntryHdr |
283 | | { |
284 | | public: |
285 | | typedef const float& KeyType; |
286 | | typedef const float* KeyTypePointer; |
287 | | |
288 | 0 | explicit nsFloatHashKey(KeyTypePointer aKey) : mValue(*aKey) {} |
289 | | nsFloatHashKey(nsFloatHashKey&& aOther) |
290 | | : PLDHashEntryHdr(std::move(aOther)) |
291 | | , mValue(std::move(aOther.mValue)) |
292 | 0 | {} |
293 | 0 | ~nsFloatHashKey() {} |
294 | | |
295 | 0 | KeyType GetKey() const { return mValue; } |
296 | 0 | bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; } |
297 | | |
298 | 0 | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
299 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
300 | 0 | { |
301 | 0 | return *reinterpret_cast<const uint32_t*>(aKey); |
302 | 0 | } |
303 | | enum { ALLOW_MEMMOVE = true }; |
304 | | |
305 | | private: |
306 | | const float mValue; |
307 | | }; |
308 | | |
309 | | /** |
310 | | * hashkey wrapper using intptr_t KeyType |
311 | | * |
312 | | * @see nsTHashtable::EntryType for specification |
313 | | */ |
314 | | class IntPtrHashKey : public PLDHashEntryHdr |
315 | | { |
316 | | public: |
317 | | typedef const intptr_t& KeyType; |
318 | | typedef const intptr_t* KeyTypePointer; |
319 | | |
320 | | explicit IntPtrHashKey(KeyTypePointer aKey) : mValue(*aKey) {} |
321 | | IntPtrHashKey(IntPtrHashKey&& aOther) |
322 | | : PLDHashEntryHdr(std::move(aOther)) |
323 | 0 | , mValue(aOther.mValue) {} |
324 | | ~IntPtrHashKey() {} |
325 | | |
326 | 0 | KeyType GetKey() const { return mValue; } |
327 | | bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; } |
328 | | |
329 | | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
330 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
331 | | { |
332 | | return mozilla::HashGeneric(*aKey); |
333 | | } |
334 | | enum { ALLOW_MEMMOVE = true }; |
335 | | |
336 | | private: |
337 | | const intptr_t mValue; |
338 | | }; |
339 | | |
340 | | /** |
341 | | * hashkey wrapper using nsISupports* KeyType |
342 | | * |
343 | | * @see nsTHashtable::EntryType for specification |
344 | | */ |
345 | | class nsISupportsHashKey : public PLDHashEntryHdr |
346 | | { |
347 | | public: |
348 | | typedef nsISupports* KeyType; |
349 | | typedef const nsISupports* KeyTypePointer; |
350 | | |
351 | | explicit nsISupportsHashKey(const nsISupports* aKey) |
352 | | : mSupports(const_cast<nsISupports*>(aKey)) |
353 | | { |
354 | | } |
355 | | nsISupportsHashKey(nsISupportsHashKey&& aOther) |
356 | | : PLDHashEntryHdr(std::move(aOther)) |
357 | | , mSupports(std::move(aOther.mSupports)) |
358 | 0 | { |
359 | 0 | } |
360 | | ~nsISupportsHashKey() {} |
361 | | |
362 | 0 | KeyType GetKey() const { return mSupports; } |
363 | | bool KeyEquals(KeyTypePointer aKey) const { return aKey == mSupports; } |
364 | | |
365 | | static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } |
366 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
367 | | { |
368 | | return NS_PTR_TO_UINT32(aKey) >> 2; |
369 | | } |
370 | | enum { ALLOW_MEMMOVE = true }; |
371 | | |
372 | | private: |
373 | | nsCOMPtr<nsISupports> mSupports; |
374 | | }; |
375 | | |
376 | | /** |
377 | | * hashkey wrapper using refcounted * KeyType |
378 | | * |
379 | | * @see nsTHashtable::EntryType for specification |
380 | | */ |
381 | | template<class T> |
382 | | class nsRefPtrHashKey : public PLDHashEntryHdr |
383 | | { |
384 | | public: |
385 | | typedef T* KeyType; |
386 | | typedef const T* KeyTypePointer; |
387 | | |
388 | 666 | explicit nsRefPtrHashKey(const T* aKey) : mKey(const_cast<T*>(aKey)) {} Unexecuted instantiation: nsRefPtrHashKey<mozilla::SchedulerGroup>::nsRefPtrHashKey(mozilla::SchedulerGroup const*) nsRefPtrHashKey<nsAtom>::nsRefPtrHashKey(nsAtom const*) Line | Count | Source | 388 | 666 | explicit nsRefPtrHashKey(const T* aKey) : mKey(const_cast<T*>(aKey)) {} |
Unexecuted instantiation: nsRefPtrHashKey<nsPermissionManager::PermissionKey>::nsRefPtrHashKey(nsPermissionManager::PermissionKey const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderUserData>::nsRefPtrHashKey(mozilla::layers::WebRenderUserData const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderCanvasData>::nsRefPtrHashKey(mozilla::layers::WebRenderCanvasData const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::TextureSource>::nsRefPtrHashKey(mozilla::layers::TextureSource const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::gfx::VRManagerParent>::nsRefPtrHashKey(mozilla::gfx::VRManagerParent const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Animation>::nsRefPtrHashKey(mozilla::dom::Animation const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::KeyframeEffect>::nsRefPtrHashKey(mozilla::dom::KeyframeEffect const*) Unexecuted instantiation: nsRefPtrHashKey<nsIWeakReference>::nsRefPtrHashKey(nsIWeakReference const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::DOMIntersectionObserver>::nsRefPtrHashKey(mozilla::dom::DOMIntersectionObserver const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MozPromise<bool, bool, false> >::nsRefPtrHashKey(mozilla::MozPromise<bool, bool, false> const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::MediaRecorder::Session>::nsRefPtrHashKey(mozilla::dom::MediaRecorder::Session const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaDecoder>::nsRefPtrHashKey(mozilla::MediaDecoder const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaRawData>::nsRefPtrHashKey(mozilla::MediaRawData const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::AudioNode>::nsRefPtrHashKey(mozilla::dom::AudioNode const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::LocalStorageCacheBridge>::nsRefPtrHashKey(mozilla::dom::LocalStorageCacheBridge const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::indexedDB::FileManager>::nsRefPtrHashKey(mozilla::dom::indexedDB::FileManager const*) Unexecuted instantiation: nsRefPtrHashKey<nsIContent>::nsRefPtrHashKey(nsIContent const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::PaymentRequest>::nsRefPtrHashKey(mozilla::dom::PaymentRequest const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Element>::nsRefPtrHashKey(mozilla::dom::Element const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::URLAndReferrerInfo>::nsRefPtrHashKey(mozilla::URLAndReferrerInfo const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::PaintedLayer>::nsRefPtrHashKey(mozilla::layers::PaintedLayer const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::a11y::Accessible>::nsRefPtrHashKey(mozilla::a11y::Accessible const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::ContentFrameMessageManager>::nsRefPtrHashKey(mozilla::dom::ContentFrameMessageManager const*) |
389 | | nsRefPtrHashKey(nsRefPtrHashKey&& aOther) |
390 | | : PLDHashEntryHdr(std::move(aOther)) |
391 | | , mKey(std::move(aOther.mKey)) |
392 | 0 | {} |
393 | 0 | ~nsRefPtrHashKey() {} Unexecuted instantiation: nsRefPtrHashKey<mozilla::SchedulerGroup>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<nsAtom>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<nsPermissionManager::PermissionKey>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderUserData>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderCanvasData>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::TextureSource>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::gfx::VRManagerParent>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Animation>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::KeyframeEffect>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<nsIWeakReference>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::DOMIntersectionObserver>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::MozPromise<bool, bool, false> >::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::MediaRecorder::Session>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaDecoder>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaRawData>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::AudioNode>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::LocalStorageCacheBridge>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::indexedDB::FileManager>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<nsIContent>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::PaymentRequest>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Element>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::URLAndReferrerInfo>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::PaintedLayer>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::a11y::Accessible>::~nsRefPtrHashKey() Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::ContentFrameMessageManager>::~nsRefPtrHashKey() |
394 | | |
395 | 0 | KeyType GetKey() const { return mKey; } Unexecuted instantiation: nsRefPtrHashKey<mozilla::SchedulerGroup>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<nsPermissionManager::PermissionKey>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderCanvasData>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderUserData>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::gfx::VRManagerParent>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::KeyframeEffect>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Animation>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<nsIWeakReference>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::DOMIntersectionObserver>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::MediaRecorder::Session>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaDecoder>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::AudioNode>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::indexedDB::FileManager>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<nsIContent>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<nsAtom>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Element>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::a11y::Accessible>::GetKey() const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::ContentFrameMessageManager>::GetKey() const |
396 | 0 | bool KeyEquals(KeyTypePointer aKey) const { return aKey == mKey; } Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Animation>::KeyEquals(mozilla::dom::Animation const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::SchedulerGroup>::KeyEquals(mozilla::SchedulerGroup const*) const Unexecuted instantiation: nsRefPtrHashKey<nsAtom>::KeyEquals(nsAtom const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderUserData>::KeyEquals(mozilla::layers::WebRenderUserData const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderCanvasData>::KeyEquals(mozilla::layers::WebRenderCanvasData const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::TextureSource>::KeyEquals(mozilla::layers::TextureSource const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::gfx::VRManagerParent>::KeyEquals(mozilla::gfx::VRManagerParent const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::KeyframeEffect>::KeyEquals(mozilla::dom::KeyframeEffect const*) const Unexecuted instantiation: nsRefPtrHashKey<nsIWeakReference>::KeyEquals(nsIWeakReference const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::DOMIntersectionObserver>::KeyEquals(mozilla::dom::DOMIntersectionObserver const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::MozPromise<bool, bool, false> >::KeyEquals(mozilla::MozPromise<bool, bool, false> const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::MediaRecorder::Session>::KeyEquals(mozilla::dom::MediaRecorder::Session const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaDecoder>::KeyEquals(mozilla::MediaDecoder const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaRawData>::KeyEquals(mozilla::MediaRawData const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::AudioNode>::KeyEquals(mozilla::dom::AudioNode const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::LocalStorageCacheBridge>::KeyEquals(mozilla::dom::LocalStorageCacheBridge const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::indexedDB::FileManager>::KeyEquals(mozilla::dom::indexedDB::FileManager const*) const Unexecuted instantiation: nsRefPtrHashKey<nsIContent>::KeyEquals(nsIContent const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::PaymentRequest>::KeyEquals(mozilla::dom::PaymentRequest const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Element>::KeyEquals(mozilla::dom::Element const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::URLAndReferrerInfo>::KeyEquals(mozilla::URLAndReferrerInfo const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::PaintedLayer>::KeyEquals(mozilla::layers::PaintedLayer const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::a11y::Accessible>::KeyEquals(mozilla::a11y::Accessible const*) const Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::ContentFrameMessageManager>::KeyEquals(mozilla::dom::ContentFrameMessageManager const*) const |
397 | | |
398 | 684 | static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } nsRefPtrHashKey<nsAtom>::KeyToPointer(nsAtom*) Line | Count | Source | 398 | 684 | static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } |
Unexecuted instantiation: nsRefPtrHashKey<nsIWeakReference>::KeyToPointer(nsIWeakReference*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::SchedulerGroup>::KeyToPointer(mozilla::SchedulerGroup*) Unexecuted instantiation: nsRefPtrHashKey<nsPermissionManager::PermissionKey>::KeyToPointer(nsPermissionManager::PermissionKey*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderUserData>::KeyToPointer(mozilla::layers::WebRenderUserData*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderCanvasData>::KeyToPointer(mozilla::layers::WebRenderCanvasData*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::TextureSource>::KeyToPointer(mozilla::layers::TextureSource*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::gfx::VRManagerParent>::KeyToPointer(mozilla::gfx::VRManagerParent*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Animation>::KeyToPointer(mozilla::dom::Animation*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::KeyframeEffect>::KeyToPointer(mozilla::dom::KeyframeEffect*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::DOMIntersectionObserver>::KeyToPointer(mozilla::dom::DOMIntersectionObserver*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::MediaRecorder::Session>::KeyToPointer(mozilla::dom::MediaRecorder::Session*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MozPromise<bool, bool, false> >::KeyToPointer(mozilla::MozPromise<bool, bool, false>*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaDecoder>::KeyToPointer(mozilla::MediaDecoder*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaRawData>::KeyToPointer(mozilla::MediaRawData*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::AudioNode>::KeyToPointer(mozilla::dom::AudioNode*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::LocalStorageCacheBridge>::KeyToPointer(mozilla::dom::LocalStorageCacheBridge*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::indexedDB::FileManager>::KeyToPointer(mozilla::dom::indexedDB::FileManager*) Unexecuted instantiation: nsRefPtrHashKey<nsIContent>::KeyToPointer(nsIContent*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::PaymentRequest>::KeyToPointer(mozilla::dom::PaymentRequest*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Element>::KeyToPointer(mozilla::dom::Element*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::URLAndReferrerInfo>::KeyToPointer(mozilla::URLAndReferrerInfo*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::PaintedLayer>::KeyToPointer(mozilla::layers::PaintedLayer*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::a11y::Accessible>::KeyToPointer(mozilla::a11y::Accessible*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::ContentFrameMessageManager>::KeyToPointer(mozilla::dom::ContentFrameMessageManager*) |
399 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
400 | 684 | { |
401 | 684 | return NS_PTR_TO_UINT32(aKey) >> 2; |
402 | 684 | } Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Animation>::HashKey(mozilla::dom::Animation const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::SchedulerGroup>::HashKey(mozilla::SchedulerGroup const*) nsRefPtrHashKey<nsAtom>::HashKey(nsAtom const*) Line | Count | Source | 400 | 684 | { | 401 | 684 | return NS_PTR_TO_UINT32(aKey) >> 2; | 402 | 684 | } |
Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderUserData>::HashKey(mozilla::layers::WebRenderUserData const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::WebRenderCanvasData>::HashKey(mozilla::layers::WebRenderCanvasData const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::TextureSource>::HashKey(mozilla::layers::TextureSource const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::gfx::VRManagerParent>::HashKey(mozilla::gfx::VRManagerParent const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::KeyframeEffect>::HashKey(mozilla::dom::KeyframeEffect const*) Unexecuted instantiation: nsRefPtrHashKey<nsIWeakReference>::HashKey(nsIWeakReference const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::DOMIntersectionObserver>::HashKey(mozilla::dom::DOMIntersectionObserver const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MozPromise<bool, bool, false> >::HashKey(mozilla::MozPromise<bool, bool, false> const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::MediaRecorder::Session>::HashKey(mozilla::dom::MediaRecorder::Session const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaDecoder>::HashKey(mozilla::MediaDecoder const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::MediaRawData>::HashKey(mozilla::MediaRawData const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::AudioNode>::HashKey(mozilla::dom::AudioNode const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::LocalStorageCacheBridge>::HashKey(mozilla::dom::LocalStorageCacheBridge const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::indexedDB::FileManager>::HashKey(mozilla::dom::indexedDB::FileManager const*) Unexecuted instantiation: nsRefPtrHashKey<nsIContent>::HashKey(nsIContent const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::PaymentRequest>::HashKey(mozilla::dom::PaymentRequest const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::Element>::HashKey(mozilla::dom::Element const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::URLAndReferrerInfo>::HashKey(mozilla::URLAndReferrerInfo const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::layers::PaintedLayer>::HashKey(mozilla::layers::PaintedLayer const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::a11y::Accessible>::HashKey(mozilla::a11y::Accessible const*) Unexecuted instantiation: nsRefPtrHashKey<mozilla::dom::ContentFrameMessageManager>::HashKey(mozilla::dom::ContentFrameMessageManager const*) |
403 | | enum { ALLOW_MEMMOVE = true }; |
404 | | |
405 | | private: |
406 | | RefPtr<T> mKey; |
407 | | }; |
408 | | |
409 | | template<class T> |
410 | | inline void |
411 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, |
412 | | nsRefPtrHashKey<T>& aField, |
413 | | const char* aName, |
414 | | uint32_t aFlags = 0) |
415 | 0 | { |
416 | 0 | CycleCollectionNoteChild(aCallback, aField.GetKey(), aName, aFlags); |
417 | 0 | } Unexecuted instantiation: void ImplCycleCollectionTraverse<mozilla::dom::Animation>(nsCycleCollectionTraversalCallback&, nsRefPtrHashKey<mozilla::dom::Animation>&, char const*, unsigned int) Unexecuted instantiation: void ImplCycleCollectionTraverse<mozilla::dom::AudioNode>(nsCycleCollectionTraversalCallback&, nsRefPtrHashKey<mozilla::dom::AudioNode>&, char const*, unsigned int) |
418 | | |
419 | | /** |
420 | | * hashkey wrapper using T* KeyType that sets key to nullptr upon |
421 | | * destruction. Relevant only in cases where a memory pointer-scanner |
422 | | * like valgrind might get confused about stale references. |
423 | | * |
424 | | * @see nsTHashtable::EntryType for specification |
425 | | */ |
426 | | |
427 | | template<class T> |
428 | | class nsClearingPtrHashKey : public nsPtrHashKey<T> |
429 | | { |
430 | | public: |
431 | | explicit nsClearingPtrHashKey(const T* aKey) : nsPtrHashKey<T>(aKey) {} |
432 | | nsClearingPtrHashKey(nsClearingPtrHashKey&& aToMove) |
433 | | : nsPtrHashKey<T>(std::move(aToMove)) |
434 | | { |
435 | | } |
436 | | ~nsClearingPtrHashKey() { nsPtrHashKey<T>::mKey = nullptr; } |
437 | | }; |
438 | | |
439 | | typedef nsClearingPtrHashKey<const void> nsClearingVoidPtrHashKey; |
440 | | |
441 | | /** |
442 | | * hashkey wrapper using a function pointer KeyType |
443 | | * |
444 | | * @see nsTHashtable::EntryType for specification |
445 | | */ |
446 | | template<class T> |
447 | | class nsFuncPtrHashKey : public PLDHashEntryHdr |
448 | | { |
449 | | public: |
450 | | typedef T& KeyType; |
451 | | typedef const T* KeyTypePointer; |
452 | | |
453 | | explicit nsFuncPtrHashKey(const T* aKey) : mKey(*const_cast<T*>(aKey)) {} |
454 | | nsFuncPtrHashKey(const nsFuncPtrHashKey<T>& aToCopy) : mKey(aToCopy.mKey) {} |
455 | | ~nsFuncPtrHashKey() {} |
456 | | |
457 | | KeyType GetKey() const { return const_cast<T&>(mKey); } |
458 | | bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mKey; } |
459 | | |
460 | | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
461 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
462 | | { |
463 | | return NS_PTR_TO_UINT32(*aKey) >> 2; |
464 | | } |
465 | | enum { ALLOW_MEMMOVE = true }; |
466 | | |
467 | | protected: |
468 | | T mKey; |
469 | | }; |
470 | | |
471 | | /** |
472 | | * hashkey wrapper using nsID KeyType |
473 | | * |
474 | | * @see nsTHashtable::EntryType for specification |
475 | | */ |
476 | | class nsIDHashKey : public PLDHashEntryHdr |
477 | | { |
478 | | public: |
479 | | typedef const nsID& KeyType; |
480 | | typedef const nsID* KeyTypePointer; |
481 | | |
482 | 0 | explicit nsIDHashKey(const nsID* aInID) : mID(*aInID) {} |
483 | | nsIDHashKey(nsIDHashKey&& aOther) |
484 | | : PLDHashEntryHdr(std::move(aOther)) |
485 | | , mID(std::move(aOther.mID)) |
486 | 0 | {} |
487 | 0 | ~nsIDHashKey() {} |
488 | | |
489 | 0 | KeyType GetKey() const { return mID; } |
490 | 0 | bool KeyEquals(KeyTypePointer aKey) const { return aKey->Equals(mID); } |
491 | | |
492 | 0 | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } |
493 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
494 | 0 | { |
495 | 0 | // Hash the nsID object's raw bytes. |
496 | 0 | return mozilla::HashBytes(aKey, sizeof(KeyType)); |
497 | 0 | } |
498 | | |
499 | | enum { ALLOW_MEMMOVE = true }; |
500 | | |
501 | | private: |
502 | | nsID mID; |
503 | | }; |
504 | | |
505 | | /** |
506 | | * hashkey wrapper using nsID* KeyType |
507 | | * |
508 | | * @see nsTHashtable::EntryType for specification |
509 | | */ |
510 | | class nsIDPointerHashKey : public PLDHashEntryHdr |
511 | | { |
512 | | public: |
513 | | typedef const nsID* KeyType; |
514 | | typedef const nsID* KeyTypePointer; |
515 | | |
516 | 1.54k | explicit nsIDPointerHashKey(const nsID* aInID) : mID(aInID) {} |
517 | | nsIDPointerHashKey(nsIDPointerHashKey&& aOther) |
518 | | : PLDHashEntryHdr(std::move(aOther)) |
519 | 0 | , mID(aOther.mID) {} |
520 | | ~nsIDPointerHashKey() = default; |
521 | | |
522 | 0 | KeyType GetKey() const { return mID; } |
523 | 1.62M | bool KeyEquals(KeyTypePointer aKey) const { return aKey->Equals(*mID); } |
524 | | |
525 | 1.62M | static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } |
526 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
527 | 1.62M | { |
528 | 1.62M | // Hash the nsID object's raw bytes. |
529 | 1.62M | return mozilla::HashBytes(aKey, sizeof(*aKey)); |
530 | 1.62M | } |
531 | | |
532 | | enum { ALLOW_MEMMOVE = true }; |
533 | | |
534 | | private: |
535 | | const nsID* mID; |
536 | | }; |
537 | | |
538 | | /** |
539 | | * hashkey wrapper for "dependent" const char*; this class does not "own" |
540 | | * its string pointer. |
541 | | * |
542 | | * This class must only be used if the strings have a lifetime longer than |
543 | | * the hashtable they occupy. This normally occurs only for static |
544 | | * strings or strings that have been arena-allocated. |
545 | | * |
546 | | * @see nsTHashtable::EntryType for specification |
547 | | */ |
548 | | class nsDepCharHashKey : public PLDHashEntryHdr |
549 | | { |
550 | | public: |
551 | | typedef const char* KeyType; |
552 | | typedef const char* KeyTypePointer; |
553 | | |
554 | | explicit nsDepCharHashKey(const char* aKey) : mKey(aKey) {} |
555 | | nsDepCharHashKey(nsDepCharHashKey&& aOther) |
556 | | : PLDHashEntryHdr(std::move(aOther)) |
557 | | , mKey(std::move(aOther.mKey)) |
558 | 0 | {} |
559 | | ~nsDepCharHashKey() {} |
560 | | |
561 | 3 | const char* GetKey() const { return mKey; } |
562 | | bool KeyEquals(const char* aKey) const { return !strcmp(mKey, aKey); } |
563 | | |
564 | | static const char* KeyToPointer(const char* aKey) { return aKey; } |
565 | | static PLDHashNumber HashKey(const char* aKey) |
566 | | { |
567 | | return mozilla::HashString(aKey); |
568 | | } |
569 | | enum { ALLOW_MEMMOVE = true }; |
570 | | |
571 | | private: |
572 | | const char* mKey; |
573 | | }; |
574 | | |
575 | | /** |
576 | | * hashkey wrapper for const char*; at construction, this class duplicates |
577 | | * a string pointed to by the pointer so that it doesn't matter whether or not |
578 | | * the string lives longer than the hash table. |
579 | | */ |
580 | | class nsCharPtrHashKey : public PLDHashEntryHdr |
581 | | { |
582 | | public: |
583 | | typedef const char* KeyType; |
584 | | typedef const char* KeyTypePointer; |
585 | | |
586 | | explicit nsCharPtrHashKey(const char* aKey) : mKey(strdup(aKey)) {} |
587 | | |
588 | | nsCharPtrHashKey(const nsCharPtrHashKey&) = delete; |
589 | | nsCharPtrHashKey(nsCharPtrHashKey&& aOther) |
590 | | : PLDHashEntryHdr(std::move(aOther)) |
591 | | , mKey(aOther.mKey) |
592 | 0 | { |
593 | 0 | aOther.mKey = nullptr; |
594 | 0 | } |
595 | | |
596 | | ~nsCharPtrHashKey() |
597 | | { |
598 | | if (mKey) { |
599 | | free(const_cast<char*>(mKey)); |
600 | | } |
601 | | } |
602 | | |
603 | | const char* GetKey() const { return mKey; } |
604 | | bool KeyEquals(KeyTypePointer aKey) const { return !strcmp(mKey, aKey); } |
605 | | |
606 | | static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } |
607 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
608 | | { |
609 | | return mozilla::HashString(aKey); |
610 | | } |
611 | | |
612 | | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
613 | 0 | { |
614 | 0 | return aMallocSizeOf(mKey); |
615 | 0 | } |
616 | | |
617 | | enum { ALLOW_MEMMOVE = true }; |
618 | | |
619 | | private: |
620 | | const char* mKey; |
621 | | }; |
622 | | |
623 | | /** |
624 | | * hashkey wrapper for const char16_t*; at construction, this class duplicates |
625 | | * a string pointed to by the pointer so that it doesn't matter whether or not |
626 | | * the string lives longer than the hash table. |
627 | | */ |
628 | | class nsUnicharPtrHashKey : public PLDHashEntryHdr |
629 | | { |
630 | | public: |
631 | | typedef const char16_t* KeyType; |
632 | | typedef const char16_t* KeyTypePointer; |
633 | | |
634 | 0 | explicit nsUnicharPtrHashKey(const char16_t* aKey) : mKey(NS_xstrdup(aKey)) {} |
635 | | nsUnicharPtrHashKey(const nsUnicharPtrHashKey& aToCopy) = delete; |
636 | | nsUnicharPtrHashKey(nsUnicharPtrHashKey&& aOther) |
637 | | : PLDHashEntryHdr(std::move(aOther)) |
638 | | , mKey(aOther.mKey) |
639 | 0 | { |
640 | 0 | aOther.mKey = nullptr; |
641 | 0 | } |
642 | | |
643 | | ~nsUnicharPtrHashKey() |
644 | 0 | { |
645 | 0 | if (mKey) { |
646 | 0 | free(const_cast<char16_t*>(mKey)); |
647 | 0 | } |
648 | 0 | } |
649 | | |
650 | 0 | const char16_t* GetKey() const { return mKey; } |
651 | 0 | bool KeyEquals(KeyTypePointer aKey) const { return !NS_strcmp(mKey, aKey); } |
652 | | |
653 | 0 | static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } |
654 | | static PLDHashNumber HashKey(KeyTypePointer aKey) |
655 | 0 | { |
656 | 0 | return mozilla::HashString(aKey); |
657 | 0 | } |
658 | | |
659 | | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
660 | 0 | { |
661 | 0 | return aMallocSizeOf(mKey); |
662 | 0 | } |
663 | | |
664 | | enum { ALLOW_MEMMOVE = true }; |
665 | | |
666 | | private: |
667 | | const char16_t* mKey; |
668 | | }; |
669 | | |
670 | | /** |
671 | | * Hashtable key class to use with objects that support nsIHashable |
672 | | */ |
673 | | class nsHashableHashKey : public PLDHashEntryHdr |
674 | | { |
675 | | public: |
676 | | typedef nsIHashable* KeyType; |
677 | | typedef const nsIHashable* KeyTypePointer; |
678 | | |
679 | | explicit nsHashableHashKey(const nsIHashable* aKey) |
680 | | : mKey(const_cast<nsIHashable*>(aKey)) |
681 | 0 | { |
682 | 0 | } |
683 | | nsHashableHashKey(nsHashableHashKey&& aOther) |
684 | | : PLDHashEntryHdr(std::move(aOther)) |
685 | | , mKey(std::move(aOther.mKey)) |
686 | 0 | {} |
687 | 0 | ~nsHashableHashKey() {} |
688 | | |
689 | 0 | nsIHashable* GetKey() const { return mKey; } |
690 | | |
691 | | bool KeyEquals(const nsIHashable* aKey) const |
692 | 0 | { |
693 | 0 | bool eq; |
694 | 0 | if (NS_SUCCEEDED(mKey->Equals(const_cast<nsIHashable*>(aKey), &eq))) { |
695 | 0 | return eq; |
696 | 0 | } |
697 | 0 | return false; |
698 | 0 | } |
699 | | |
700 | 0 | static const nsIHashable* KeyToPointer(nsIHashable* aKey) { return aKey; } |
701 | | static PLDHashNumber HashKey(const nsIHashable* aKey) |
702 | 0 | { |
703 | 0 | uint32_t code = 8888; // magic number if GetHashCode fails :-( |
704 | 0 | #ifdef DEBUG |
705 | 0 | nsresult rv = |
706 | 0 | #endif |
707 | 0 | const_cast<nsIHashable*>(aKey)->GetHashCode(&code); |
708 | 0 | NS_ASSERTION(NS_SUCCEEDED(rv), "GetHashCode should not throw!"); |
709 | 0 | return code; |
710 | 0 | } |
711 | | |
712 | | enum { ALLOW_MEMMOVE = true }; |
713 | | |
714 | | private: |
715 | | nsCOMPtr<nsIHashable> mKey; |
716 | | }; |
717 | | |
718 | | namespace mozilla { |
719 | | |
720 | | template <typename T> |
721 | | PLDHashNumber |
722 | | Hash(const T& aValue) |
723 | 0 | { |
724 | 0 | return aValue.Hash(); |
725 | 0 | } Unexecuted instantiation: unsigned int mozilla::Hash<mozilla::dom::ipc::StringTableEntry>(mozilla::dom::ipc::StringTableEntry const&) Unexecuted instantiation: unsigned int mozilla::Hash<nsHostKey>(nsHostKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<mozilla::URLPreloader::CacheKey>(mozilla::URLPreloader::CacheKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<mozilla::layers::WebRenderUserDataKey>(mozilla::layers::WebRenderUserDataKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<mozilla::image::SurfaceKey>(mozilla::image::SurfaceKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<mozilla::image::ImageCacheKey>(mozilla::image::ImageCacheKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<nsTreeStyleCache::Transition>(nsTreeStyleCache::Transition const&) Unexecuted instantiation: unsigned int mozilla::Hash<mozilla::ContainerState::MaskLayerKey>(mozilla::ContainerState::MaskLayerKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<JITFrameInfoForBufferRange::JITFrameKey>(JITFrameInfoForBufferRange::JITFrameKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<UniqueStacks::FrameKey>(UniqueStacks::FrameKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<UniqueStacks::StackKey>(UniqueStacks::StackKey const&) Unexecuted instantiation: unsigned int mozilla::Hash<CertBlocklistItem>(CertBlocklistItem const&) |
726 | | |
727 | | } // namespace mozilla |
728 | | |
729 | | /** |
730 | | * Hashtable key class to use with objects for which Hash() and operator==() |
731 | | * are defined. |
732 | | */ |
733 | | template<typename T> |
734 | | class nsGenericHashKey : public PLDHashEntryHdr |
735 | | { |
736 | | public: |
737 | | typedef const T& KeyType; |
738 | | typedef const T* KeyTypePointer; |
739 | | |
740 | 0 | explicit nsGenericHashKey(KeyTypePointer aKey) : mKey(*aKey) {} Unexecuted instantiation: nsGenericHashKey<mozilla::dom::ipc::StringTableEntry>::nsGenericHashKey(mozilla::dom::ipc::StringTableEntry const*) Unexecuted instantiation: nsGenericHashKey<nsHostKey>::nsGenericHashKey(nsHostKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::URLPreloader::CacheKey>::nsGenericHashKey(mozilla::URLPreloader::CacheKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::layers::WebRenderUserDataKey>::nsGenericHashKey(mozilla::layers::WebRenderUserDataKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::image::SurfaceKey>::nsGenericHashKey(mozilla::image::SurfaceKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::image::ImageCacheKey>::nsGenericHashKey(mozilla::image::ImageCacheKey const*) Unexecuted instantiation: nsGenericHashKey<nsTreeStyleCache::Transition>::nsGenericHashKey(nsTreeStyleCache::Transition const*) Unexecuted instantiation: nsGenericHashKey<mozilla::ContainerState::MaskLayerKey>::nsGenericHashKey(mozilla::ContainerState::MaskLayerKey const*) Unexecuted instantiation: nsGenericHashKey<JITFrameInfoForBufferRange::JITFrameKey>::nsGenericHashKey(JITFrameInfoForBufferRange::JITFrameKey const*) Unexecuted instantiation: nsGenericHashKey<UniqueStacks::FrameKey>::nsGenericHashKey(UniqueStacks::FrameKey const*) Unexecuted instantiation: nsGenericHashKey<UniqueStacks::StackKey>::nsGenericHashKey(UniqueStacks::StackKey const*) Unexecuted instantiation: nsGenericHashKey<CertBlocklistItem>::nsGenericHashKey(CertBlocklistItem const*) |
741 | | nsGenericHashKey(const nsGenericHashKey&) = delete; |
742 | | nsGenericHashKey(nsGenericHashKey&& aOther) |
743 | | : PLDHashEntryHdr(std::move(aOther)) |
744 | | , mKey(std::move(aOther.mKey)) {} |
745 | | |
746 | 0 | KeyType GetKey() const { return mKey; } Unexecuted instantiation: nsGenericHashKey<mozilla::image::ImageCacheKey>::GetKey() const Unexecuted instantiation: nsGenericHashKey<JITFrameInfoForBufferRange::JITFrameKey>::GetKey() const Unexecuted instantiation: nsGenericHashKey<CertBlocklistItem>::GetKey() const |
747 | 0 | bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mKey; } Unexecuted instantiation: nsGenericHashKey<mozilla::dom::ipc::StringTableEntry>::KeyEquals(mozilla::dom::ipc::StringTableEntry const*) const Unexecuted instantiation: nsGenericHashKey<nsHostKey>::KeyEquals(nsHostKey const*) const Unexecuted instantiation: nsGenericHashKey<mozilla::URLPreloader::CacheKey>::KeyEquals(mozilla::URLPreloader::CacheKey const*) const Unexecuted instantiation: nsGenericHashKey<mozilla::layers::WebRenderUserDataKey>::KeyEquals(mozilla::layers::WebRenderUserDataKey const*) const Unexecuted instantiation: nsGenericHashKey<mozilla::image::SurfaceKey>::KeyEquals(mozilla::image::SurfaceKey const*) const Unexecuted instantiation: nsGenericHashKey<mozilla::image::ImageCacheKey>::KeyEquals(mozilla::image::ImageCacheKey const*) const Unexecuted instantiation: nsGenericHashKey<nsTreeStyleCache::Transition>::KeyEquals(nsTreeStyleCache::Transition const*) const Unexecuted instantiation: nsGenericHashKey<mozilla::ContainerState::MaskLayerKey>::KeyEquals(mozilla::ContainerState::MaskLayerKey const*) const Unexecuted instantiation: nsGenericHashKey<JITFrameInfoForBufferRange::JITFrameKey>::KeyEquals(JITFrameInfoForBufferRange::JITFrameKey const*) const Unexecuted instantiation: nsGenericHashKey<UniqueStacks::FrameKey>::KeyEquals(UniqueStacks::FrameKey const*) const Unexecuted instantiation: nsGenericHashKey<UniqueStacks::StackKey>::KeyEquals(UniqueStacks::StackKey const*) const Unexecuted instantiation: nsGenericHashKey<CertBlocklistItem>::KeyEquals(CertBlocklistItem const*) const |
748 | | |
749 | 0 | static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } Unexecuted instantiation: nsGenericHashKey<mozilla::dom::ipc::StringTableEntry>::KeyToPointer(mozilla::dom::ipc::StringTableEntry const&) Unexecuted instantiation: nsGenericHashKey<nsHostKey>::KeyToPointer(nsHostKey const&) Unexecuted instantiation: nsGenericHashKey<mozilla::URLPreloader::CacheKey>::KeyToPointer(mozilla::URLPreloader::CacheKey const&) Unexecuted instantiation: nsGenericHashKey<mozilla::layers::WebRenderUserDataKey>::KeyToPointer(mozilla::layers::WebRenderUserDataKey const&) Unexecuted instantiation: nsGenericHashKey<mozilla::image::SurfaceKey>::KeyToPointer(mozilla::image::SurfaceKey const&) Unexecuted instantiation: nsGenericHashKey<mozilla::image::ImageCacheKey>::KeyToPointer(mozilla::image::ImageCacheKey const&) Unexecuted instantiation: nsGenericHashKey<nsTreeStyleCache::Transition>::KeyToPointer(nsTreeStyleCache::Transition const&) Unexecuted instantiation: nsGenericHashKey<mozilla::ContainerState::MaskLayerKey>::KeyToPointer(mozilla::ContainerState::MaskLayerKey const&) Unexecuted instantiation: nsGenericHashKey<JITFrameInfoForBufferRange::JITFrameKey>::KeyToPointer(JITFrameInfoForBufferRange::JITFrameKey const&) Unexecuted instantiation: nsGenericHashKey<UniqueStacks::StackKey>::KeyToPointer(UniqueStacks::StackKey const&) Unexecuted instantiation: nsGenericHashKey<UniqueStacks::FrameKey>::KeyToPointer(UniqueStacks::FrameKey const&) Unexecuted instantiation: nsGenericHashKey<CertBlocklistItem>::KeyToPointer(CertBlocklistItem const&) |
750 | 0 | static PLDHashNumber HashKey(KeyTypePointer aKey) { return ::mozilla::Hash(*aKey); } Unexecuted instantiation: nsGenericHashKey<mozilla::dom::ipc::StringTableEntry>::HashKey(mozilla::dom::ipc::StringTableEntry const*) Unexecuted instantiation: nsGenericHashKey<nsHostKey>::HashKey(nsHostKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::URLPreloader::CacheKey>::HashKey(mozilla::URLPreloader::CacheKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::layers::WebRenderUserDataKey>::HashKey(mozilla::layers::WebRenderUserDataKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::image::SurfaceKey>::HashKey(mozilla::image::SurfaceKey const*) Unexecuted instantiation: nsGenericHashKey<mozilla::image::ImageCacheKey>::HashKey(mozilla::image::ImageCacheKey const*) Unexecuted instantiation: nsGenericHashKey<nsTreeStyleCache::Transition>::HashKey(nsTreeStyleCache::Transition const*) Unexecuted instantiation: nsGenericHashKey<mozilla::ContainerState::MaskLayerKey>::HashKey(mozilla::ContainerState::MaskLayerKey const*) Unexecuted instantiation: nsGenericHashKey<JITFrameInfoForBufferRange::JITFrameKey>::HashKey(JITFrameInfoForBufferRange::JITFrameKey const*) Unexecuted instantiation: nsGenericHashKey<UniqueStacks::FrameKey>::HashKey(UniqueStacks::FrameKey const*) Unexecuted instantiation: nsGenericHashKey<UniqueStacks::StackKey>::HashKey(UniqueStacks::StackKey const*) Unexecuted instantiation: nsGenericHashKey<CertBlocklistItem>::HashKey(CertBlocklistItem const*) |
751 | | enum { ALLOW_MEMMOVE = true }; |
752 | | |
753 | | private: |
754 | | T mKey; |
755 | | }; |
756 | | |
757 | | #endif // nsTHashKeys_h__ |