/src/mozilla-central/xpcom/ds/nsTHashtable.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 | | // See the comment at the top of mfbt/HashTable.h for a comparison between |
8 | | // PLDHashTable and mozilla::HashTable. |
9 | | |
10 | | #ifndef nsTHashtable_h__ |
11 | | #define nsTHashtable_h__ |
12 | | |
13 | | #include "PLDHashTable.h" |
14 | | #include "nsPointerHashKeys.h" |
15 | | #include "mozilla/Assertions.h" |
16 | | #include "mozilla/Attributes.h" |
17 | | #include "mozilla/fallible.h" |
18 | | #include "mozilla/MemoryReporting.h" |
19 | | #include "mozilla/Move.h" |
20 | | #include "mozilla/OperatorNewExtensions.h" |
21 | | #include "mozilla/PodOperations.h" |
22 | | #include "mozilla/TypeTraits.h" |
23 | | |
24 | | #include <new> |
25 | | |
26 | | /** |
27 | | * a base class for templated hashtables. |
28 | | * |
29 | | * Clients will rarely need to use this class directly. Check the derived |
30 | | * classes first, to see if they will meet your needs. |
31 | | * |
32 | | * @param EntryType the templated entry-type class that is managed by the |
33 | | * hashtable. <code>EntryType</code> must extend the following declaration, |
34 | | * and <strong>must not declare any virtual functions or derive from classes |
35 | | * with virtual functions.</strong> Any vtable pointer would break the |
36 | | * PLDHashTable code. |
37 | | *<pre> class EntryType : public PLDHashEntryHdr |
38 | | * { |
39 | | * public: or friend nsTHashtable<EntryType>; |
40 | | * // KeyType is what we use when Get()ing or Put()ing this entry |
41 | | * // this should either be a simple datatype (uint32_t, nsISupports*) or |
42 | | * // a const reference (const nsAString&) |
43 | | * typedef something KeyType; |
44 | | * // KeyTypePointer is the pointer-version of KeyType, because |
45 | | * // PLDHashTable.h requires keys to cast to <code>const void*</code> |
46 | | * typedef const something* KeyTypePointer; |
47 | | * |
48 | | * EntryType(KeyTypePointer aKey); |
49 | | * |
50 | | * // A copy or C++11 Move constructor must be defined, even if |
51 | | * // AllowMemMove() == true, otherwise you will cause link errors. |
52 | | * EntryType(const EntryType& aEnt); // Either this... |
53 | | * EntryType(EntryType&& aEnt); // ...or this |
54 | | * |
55 | | * // the destructor must be defined... or you will cause link errors! |
56 | | * ~EntryType(); |
57 | | * |
58 | | * // KeyEquals(): does this entry match this key? |
59 | | * bool KeyEquals(KeyTypePointer aKey) const; |
60 | | * |
61 | | * // KeyToPointer(): Convert KeyType to KeyTypePointer |
62 | | * static KeyTypePointer KeyToPointer(KeyType aKey); |
63 | | * |
64 | | * // HashKey(): calculate the hash number |
65 | | * static PLDHashNumber HashKey(KeyTypePointer aKey); |
66 | | * |
67 | | * // ALLOW_MEMMOVE can we move this class with memmove(), or do we have |
68 | | * // to use the copy constructor? |
69 | | * enum { ALLOW_MEMMOVE = true/false }; |
70 | | * }</pre> |
71 | | * |
72 | | * @see nsInterfaceHashtable |
73 | | * @see nsDataHashtable |
74 | | * @see nsClassHashtable |
75 | | * @author "Benjamin Smedberg <bsmedberg@covad.net>" |
76 | | */ |
77 | | |
78 | | template<class EntryType> |
79 | | class MOZ_NEEDS_NO_VTABLE_TYPE nsTHashtable |
80 | | { |
81 | | typedef mozilla::fallible_t fallible_t; |
82 | | static_assert(mozilla::IsPointer<typename EntryType::KeyTypePointer>::value, |
83 | | "KeyTypePointer should be a pointer"); |
84 | | |
85 | | public: |
86 | | // Separate constructors instead of default aInitLength parameter since |
87 | | // otherwise the default no-arg constructor isn't found. |
88 | | nsTHashtable() |
89 | | : mTable(Ops(), sizeof(EntryType), PLDHashTable::kDefaultInitialLength) |
90 | 24 | {} nsTHashtable<detail::VoidPtrHashKey>::nsTHashtable() Line | Count | Source | 90 | 3 | {} |
nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::nsTHashtable() Line | Count | Source | 90 | 3 | {} |
nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::nsTHashtable() Line | Count | Source | 90 | 3 | {} |
nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::nsTHashtable() Line | Count | Source | 90 | 1 | {} |
nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::nsTHashtable() Line | Count | Source | 90 | 5 | {} |
nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::nsTHashtable() Line | Count | Source | 90 | 3 | {} |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::nsTHashtable() Line | Count | Source | 90 | 3 | {} |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::nsTHashtable() nsTHashtable<nsObserverList>::nsTHashtable() Line | Count | Source | 90 | 3 | {} |
|
91 | | explicit nsTHashtable(uint32_t aInitLength) |
92 | | : mTable(Ops(), sizeof(EntryType), aInitLength) |
93 | 6 | {} nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::nsTHashtable(unsigned int) Line | Count | Source | 93 | 3 | {} |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::nsTHashtable(unsigned int) Line | Count | Source | 93 | 3 | {} |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::nsTHashtable(unsigned int) Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::nsTHashtable(unsigned int) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::nsTHashtable(unsigned int) Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::nsTHashtable(unsigned int) |
94 | | |
95 | | /** |
96 | | * destructor, cleans up and deallocates |
97 | | */ |
98 | | ~nsTHashtable(); |
99 | | |
100 | | nsTHashtable(nsTHashtable<EntryType>&& aOther); |
101 | | |
102 | | /** |
103 | | * Return the generation number for the table. This increments whenever |
104 | | * the table data items are moved. |
105 | | */ |
106 | | uint32_t GetGeneration() const { return mTable.Generation(); } |
107 | | |
108 | | /** |
109 | | * KeyType is typedef'ed for ease of use. |
110 | | */ |
111 | | typedef typename EntryType::KeyType KeyType; |
112 | | |
113 | | /** |
114 | | * KeyTypePointer is typedef'ed for ease of use. |
115 | | */ |
116 | | typedef typename EntryType::KeyTypePointer KeyTypePointer; |
117 | | |
118 | | /** |
119 | | * Return the number of entries in the table. |
120 | | * @return number of entries |
121 | | */ |
122 | 15.0M | uint32_t Count() const { return mTable.EntryCount(); } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::Count() const nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::Count() const Line | Count | Source | 122 | 6 | uint32_t Count() const { return mTable.EntryCount(); } |
nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::Count() const Line | Count | Source | 122 | 15.0M | uint32_t Count() const { return mTable.EntryCount(); } |
nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::Count() const Line | Count | Source | 122 | 8.90k | uint32_t Count() const { return mTable.EntryCount(); } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::Count() const |
123 | | |
124 | | /** |
125 | | * Return true if the hashtable is empty. |
126 | | */ |
127 | | bool IsEmpty() const { return Count() == 0; } |
128 | | |
129 | | /** |
130 | | * Get the entry associated with a key. |
131 | | * @param aKey the key to retrieve |
132 | | * @return pointer to the entry class, if the key exists; nullptr if the |
133 | | * key doesn't exist |
134 | | */ |
135 | | EntryType* GetEntry(KeyType aKey) const |
136 | 266 | { |
137 | 266 | return static_cast<EntryType*>( |
138 | 266 | mTable.Search(EntryType::KeyToPointer(aKey))); |
139 | 266 | } nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::GetEntry(char const*) const Line | Count | Source | 136 | 75 | { | 137 | 75 | return static_cast<EntryType*>( | 138 | 75 | mTable.Search(EntryType::KeyToPointer(aKey))); | 139 | 75 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::GetEntry(void*) const Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::GetEntry(nsISupports*) const Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::GetEntry(unsigned int const&) const Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::GetEntry(char const*) const Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::GetEntry(char const*) const Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::GetEntry(long const&) const Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::GetEntry(void const*) const nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::GetEntry(nsIMemoryReporter*) const Line | Count | Source | 136 | 85 | { | 137 | 85 | return static_cast<EntryType*>( | 138 | 85 | mTable.Search(EntryType::KeyToPointer(aKey))); | 139 | 85 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::GetEntry(nsIMemoryReporter*) const Line | Count | Source | 136 | 85 | { | 137 | 85 | return static_cast<EntryType*>( | 138 | 85 | mTable.Search(EntryType::KeyToPointer(aKey))); | 139 | 85 | } |
Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::GetEntry(char const*) const Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::GetEntry(nsTSubstring<char16_t> const&) const nsTHashtable<nsObserverList>::GetEntry(char const*) const Line | Count | Source | 136 | 21 | { | 137 | 21 | return static_cast<EntryType*>( | 138 | 21 | mTable.Search(EntryType::KeyToPointer(aKey))); | 139 | 21 | } |
|
140 | | |
141 | | /** |
142 | | * Return true if an entry for the given key exists, false otherwise. |
143 | | * @param aKey the key to retrieve |
144 | | * @return true if the key exists, false if the key doesn't exist |
145 | | */ |
146 | 170 | bool Contains(KeyType aKey) const { return !!GetEntry(aKey); } Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::Contains(long const&) const nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::Contains(nsIMemoryReporter*) const Line | Count | Source | 146 | 85 | bool Contains(KeyType aKey) const { return !!GetEntry(aKey); } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::Contains(nsIMemoryReporter*) const Line | Count | Source | 146 | 85 | bool Contains(KeyType aKey) const { return !!GetEntry(aKey); } |
Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::Contains(char const*) const |
147 | | |
148 | | /** |
149 | | * Infallibly get the entry associated with a key, or create a new entry, |
150 | | * @param aKey the key to retrieve |
151 | | * @return pointer to the entry retrieved; never nullptr |
152 | | */ |
153 | | EntryType* PutEntry(KeyType aKey) |
154 | 7.50M | { |
155 | 7.50M | // infallible add |
156 | 7.50M | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey))); |
157 | 7.50M | } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::PutEntry(void const*) nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::PutEntry(void*) Line | Count | Source | 154 | 3 | { | 155 | 3 | // infallible add | 156 | 3 | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey))); | 157 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::PutEntry(bool (*&)(unsigned int, void*)) Line | Count | Source | 154 | 7.50M | { | 155 | 7.50M | // infallible add | 156 | 7.50M | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey))); | 157 | 7.50M | } |
Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::PutEntry(char const*) Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::PutEntry(long const&) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::PutEntry(void const*) nsTHashtable<nsObserverList>::PutEntry(char const*) Line | Count | Source | 154 | 347 | { | 155 | 347 | // infallible add | 156 | 347 | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey))); | 157 | 347 | } |
|
158 | | |
159 | | /** |
160 | | * Fallibly get the entry associated with a key, or create a new entry, |
161 | | * @param aKey the key to retrieve |
162 | | * @return pointer to the entry retrieved; nullptr only if memory can't |
163 | | * be allocated |
164 | | */ |
165 | | MOZ_MUST_USE |
166 | | EntryType* PutEntry(KeyType aKey, const fallible_t&) |
167 | 166 | { |
168 | 166 | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey), |
169 | 166 | mozilla::fallible)); |
170 | 166 | } nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::PutEntry(char const*, std::nothrow_t const&) Line | Count | Source | 167 | 75 | { | 168 | 75 | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey), | 169 | 75 | mozilla::fallible)); | 170 | 75 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::PutEntry(void*, std::nothrow_t const&) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::PutEntry(nsISupports*, std::nothrow_t const&) nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::PutEntry(unsigned int const&, std::nothrow_t const&) Line | Count | Source | 167 | 6 | { | 168 | 6 | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey), | 169 | 6 | mozilla::fallible)); | 170 | 6 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::PutEntry(char const*, std::nothrow_t const&) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::PutEntry(char const*, std::nothrow_t const&) nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::PutEntry(nsIMemoryReporter*, std::nothrow_t const&) Line | Count | Source | 167 | 52 | { | 168 | 52 | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey), | 169 | 52 | mozilla::fallible)); | 170 | 52 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::PutEntry(nsIMemoryReporter*, std::nothrow_t const&) Line | Count | Source | 167 | 33 | { | 168 | 33 | return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey), | 169 | 33 | mozilla::fallible)); | 170 | 33 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::PutEntry(nsTSubstring<char16_t> const&, std::nothrow_t const&) |
171 | | |
172 | | /** |
173 | | * Get the entry associated with a key, or create a new entry using infallible |
174 | | * allocation and insert that. |
175 | | * @param aKey the key to retrieve |
176 | | * @param aEntry will be assigned (if non-null) to the entry that was found |
177 | | * or created |
178 | | * @return true if a new entry was created, or false if an existing entry |
179 | | * was found |
180 | | */ |
181 | | MOZ_MUST_USE |
182 | | bool EnsureInserted(KeyType aKey, EntryType** aEntry = nullptr) |
183 | | { |
184 | | auto oldCount = Count(); |
185 | | EntryType* entry = PutEntry(aKey); |
186 | | if (aEntry) { |
187 | | *aEntry = entry; |
188 | | } |
189 | | return oldCount != Count(); |
190 | | } |
191 | | |
192 | | /** |
193 | | * Remove the entry associated with a key. |
194 | | * @param aKey of the entry to remove |
195 | | */ |
196 | | void RemoveEntry(KeyType aKey) |
197 | | { |
198 | | mTable.Remove(EntryType::KeyToPointer(aKey)); |
199 | | } |
200 | | |
201 | | /** |
202 | | * Lookup the entry associated with aKey and remove it if found, otherwise |
203 | | * do nothing. |
204 | | * @param aKey of the entry to remove |
205 | | * @return true if an entry was found and removed, or false if no entry |
206 | | * was found for aKey |
207 | | */ |
208 | | bool EnsureRemoved(KeyType aKey) |
209 | | { |
210 | | auto* entry = GetEntry(aKey); |
211 | | if (entry) { |
212 | | RemoveEntry(entry); |
213 | | return true; |
214 | | } |
215 | | return false; |
216 | | } |
217 | | |
218 | | /** |
219 | | * Remove the entry associated with a key. |
220 | | * @param aEntry the entry-pointer to remove (obtained from GetEntry) |
221 | | */ |
222 | | void RemoveEntry(EntryType* aEntry) |
223 | 0 | { |
224 | 0 | mTable.RemoveEntry(aEntry); |
225 | 0 | } Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::RemoveEntry(nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*>*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::RemoveEntry(nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> >*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::RemoveEntry(nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > >*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::RemoveEntry(nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> >*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::RemoveEntry(nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> >*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::RemoveEntry(nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool>*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::RemoveEntry(nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool>*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::RemoveEntry(nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> >*) |
226 | | |
227 | | /** |
228 | | * Remove the entry associated with a key, but don't resize the hashtable. |
229 | | * This is a low-level method, and is not recommended unless you know what |
230 | | * you're doing. If you use it, please add a comment explaining why you |
231 | | * didn't use RemoveEntry(). |
232 | | * @param aEntry the entry-pointer to remove (obtained from GetEntry) |
233 | | */ |
234 | | void RawRemoveEntry(EntryType* aEntry) |
235 | | { |
236 | | mTable.RawRemove(aEntry); |
237 | | } |
238 | | |
239 | | // This is an iterator that also allows entry removal. Example usage: |
240 | | // |
241 | | // for (auto iter = table.Iter(); !iter.Done(); iter.Next()) { |
242 | | // Entry* entry = iter.Get(); |
243 | | // // ... do stuff with |entry| ... |
244 | | // // ... possibly call iter.Remove() once ... |
245 | | // } |
246 | | // |
247 | | class Iterator : public PLDHashTable::Iterator |
248 | | { |
249 | | public: |
250 | | typedef PLDHashTable::Iterator Base; |
251 | | |
252 | 0 | explicit Iterator(nsTHashtable* aTable) : Base(&aTable->mTable) {} Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::Iterator::Iterator(nsTHashtable<detail::VoidPtrHashKey>*) Unexecuted instantiation: nsTHashtable<nsObserverList>::Iterator::Iterator(nsTHashtable<nsObserverList>*) |
253 | | Iterator(Iterator&& aOther) : Base(aOther.mTable) {} |
254 | | ~Iterator() {} |
255 | | |
256 | 0 | EntryType* Get() const { return static_cast<EntryType*>(Base::Get()); } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::Iterator::Get() const Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::Iterator::Get() const Unexecuted instantiation: nsTHashtable<nsObserverList>::Iterator::Get() const |
257 | | |
258 | | private: |
259 | | Iterator() = delete; |
260 | | Iterator(const Iterator&) = delete; |
261 | | Iterator& operator=(const Iterator&) = delete; |
262 | | Iterator& operator=(const Iterator&&) = delete; |
263 | | }; |
264 | | |
265 | 0 | Iterator Iter() { return Iterator(this); } |
266 | | |
267 | | Iterator ConstIter() const |
268 | 0 | { |
269 | 0 | return Iterator(const_cast<nsTHashtable*>(this)); |
270 | 0 | } |
271 | | |
272 | | /** |
273 | | * Remove all entries, return hashtable to "pristine" state. It's |
274 | | * conceptually the same as calling the destructor and then re-calling the |
275 | | * constructor. |
276 | | */ |
277 | | void Clear() |
278 | 18 | { |
279 | 18 | mTable.Clear(); |
280 | 18 | } nsTHashtable<detail::VoidPtrHashKey>::Clear() Line | Count | Source | 278 | 18 | { | 279 | 18 | mTable.Clear(); | 280 | 18 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::Clear() Unexecuted instantiation: nsTHashtable<nsObserverList>::Clear() |
281 | | |
282 | | /** |
283 | | * Measure the size of the table's entry storage. Does *not* measure anything |
284 | | * hanging off table entries; hence the "Shallow" prefix. To measure that, |
285 | | * either use SizeOfExcludingThis() or iterate manually over the entries, |
286 | | * calling SizeOfExcludingThis() on each one. |
287 | | * |
288 | | * @param aMallocSizeOf the function used to measure heap-allocated blocks |
289 | | * @return the measured shallow size of the table |
290 | | */ |
291 | | size_t ShallowSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
292 | 0 | { |
293 | 0 | return mTable.ShallowSizeOfExcludingThis(aMallocSizeOf); |
294 | 0 | } |
295 | | |
296 | | /** |
297 | | * Like ShallowSizeOfExcludingThis, but includes sizeof(*this). |
298 | | */ |
299 | | size_t ShallowSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
300 | | { |
301 | | return aMallocSizeOf(this) + ShallowSizeOfExcludingThis(aMallocSizeOf); |
302 | | } |
303 | | |
304 | | /** |
305 | | * This is a "deep" measurement of the table. To use it, |EntryType| must |
306 | | * define SizeOfExcludingThis, and that method will be called on all live |
307 | | * entries. |
308 | | */ |
309 | | size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
310 | 0 | { |
311 | 0 | size_t n = ShallowSizeOfExcludingThis(aMallocSizeOf); |
312 | 0 | for (auto iter = ConstIter(); !iter.Done(); iter.Next()) { |
313 | 0 | n += (*iter.Get()).SizeOfExcludingThis(aMallocSizeOf); |
314 | 0 | } |
315 | 0 | return n; |
316 | 0 | } |
317 | | |
318 | | /** |
319 | | * Like SizeOfExcludingThis, but includes sizeof(*this). |
320 | | */ |
321 | | size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const |
322 | | { |
323 | | return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); |
324 | | } |
325 | | |
326 | | /** |
327 | | * Swap the elements in this hashtable with the elements in aOther. |
328 | | */ |
329 | | void SwapElements(nsTHashtable<EntryType>& aOther) |
330 | | { |
331 | | MOZ_ASSERT_IF(this->mTable.Ops() && aOther.mTable.Ops(), |
332 | | this->mTable.Ops() == aOther.mTable.Ops()); |
333 | | mozilla::Swap(this->mTable, aOther.mTable); |
334 | | } |
335 | | |
336 | | #ifdef DEBUG |
337 | | /** |
338 | | * Mark the table as constant after initialization. |
339 | | * |
340 | | * This will prevent assertions when a read-only hash is accessed on multiple |
341 | | * threads without synchronization. |
342 | | */ |
343 | | void MarkImmutable() |
344 | | { |
345 | | mTable.MarkImmutable(); |
346 | | } |
347 | | #endif |
348 | | |
349 | | protected: |
350 | | PLDHashTable mTable; |
351 | | |
352 | | static PLDHashNumber s_HashKey(const void* aKey); |
353 | | |
354 | | static bool s_MatchEntry(const PLDHashEntryHdr* aEntry, |
355 | | const void* aKey); |
356 | | |
357 | | static void s_CopyEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom, |
358 | | PLDHashEntryHdr* aTo); |
359 | | |
360 | | static void s_ClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry); |
361 | | |
362 | | static void s_InitEntry(PLDHashEntryHdr* aEntry, const void* aKey); |
363 | | |
364 | | private: |
365 | | // copy constructor, not implemented |
366 | | nsTHashtable(nsTHashtable<EntryType>& aToCopy) = delete; |
367 | | |
368 | | /** |
369 | | * Gets the table's ops. |
370 | | */ |
371 | | static const PLDHashTableOps* Ops(); |
372 | | |
373 | | // assignment operator, not implemented |
374 | | nsTHashtable<EntryType>& operator=(nsTHashtable<EntryType>& aToEqual) = delete; |
375 | | }; |
376 | | |
377 | | namespace mozilla { |
378 | | namespace detail { |
379 | | |
380 | | // Like PLDHashTable::MoveEntryStub, but specialized for fixed N (i.e. the size |
381 | | // of the entries in the hashtable). Saves a memory read to figure out the size |
382 | | // from the table and gives the compiler the opportunity to inline the memcpy. |
383 | | // |
384 | | // We define this outside of nsTHashtable so only one copy exists for every N, |
385 | | // rather than separate copies for every EntryType used with nsTHashtable. |
386 | | template<size_t N> |
387 | | static void |
388 | | FixedSizeEntryMover(PLDHashTable*, |
389 | | const PLDHashEntryHdr* aFrom, |
390 | | PLDHashEntryHdr* aTo) |
391 | 342 | { |
392 | 342 | memcpy(aTo, aFrom, N); |
393 | 342 | } Unexecuted instantiation: Unified_cpp_xpcom_base0.cpp:void mozilla::detail::FixedSizeEntryMover<16ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_base0.cpp:void mozilla::detail::FixedSizeEntryMover<24ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_base0.cpp:void mozilla::detail::FixedSizeEntryMover<32ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_base1.cpp:void mozilla::detail::FixedSizeEntryMover<16ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_base1.cpp:void mozilla::detail::FixedSizeEntryMover<24ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_base2.cpp:void mozilla::detail::FixedSizeEntryMover<32ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unified_cpp_xpcom_base2.cpp:void mozilla::detail::FixedSizeEntryMover<24ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Line | Count | Source | 391 | 72 | { | 392 | 72 | memcpy(aTo, aFrom, N); | 393 | 72 | } |
Unexecuted instantiation: Unified_cpp_xpcom_base2.cpp:void mozilla::detail::FixedSizeEntryMover<16ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unified_cpp_xpcom_ds0.cpp:void mozilla::detail::FixedSizeEntryMover<24ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Line | Count | Source | 391 | 270 | { | 392 | 270 | memcpy(aTo, aFrom, N); | 393 | 270 | } |
Unexecuted instantiation: Unified_cpp_xpcom_ds0.cpp:void mozilla::detail::FixedSizeEntryMover<32ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_build0.cpp:void mozilla::detail::FixedSizeEntryMover<32ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_build0.cpp:void mozilla::detail::FixedSizeEntryMover<24ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_xpcom_build0.cpp:void mozilla::detail::FixedSizeEntryMover<16ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_dom_base5.cpp:void mozilla::detail::FixedSizeEntryMover<16ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_dom_base5.cpp:void mozilla::detail::FixedSizeEntryMover<32ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: Unified_cpp_dom_base5.cpp:void mozilla::detail::FixedSizeEntryMover<24ul>(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) |
394 | | |
395 | | } // namespace detail |
396 | | } // namespace mozilla |
397 | | |
398 | | // |
399 | | // template definitions |
400 | | // |
401 | | |
402 | | template<class EntryType> |
403 | | nsTHashtable<EntryType>::nsTHashtable(nsTHashtable<EntryType>&& aOther) |
404 | | : mTable(std::move(aOther.mTable)) |
405 | 0 | { |
406 | 0 | } |
407 | | |
408 | | template<class EntryType> |
409 | | nsTHashtable<EntryType>::~nsTHashtable() |
410 | 5 | { |
411 | 5 | } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::~nsTHashtable() nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::~nsTHashtable() Line | Count | Source | 410 | 5 | { | 411 | 5 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::~nsTHashtable() Unexecuted instantiation: nsTHashtable<nsObserverList>::~nsTHashtable() |
412 | | |
413 | | template<class EntryType> |
414 | | /* static */ const PLDHashTableOps* |
415 | | nsTHashtable<EntryType>::Ops() |
416 | 30 | { |
417 | 30 | // If this variable is a global variable, we get strange start-up failures on |
418 | 30 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a |
419 | 30 | // function avoids that problem. |
420 | 30 | static const PLDHashTableOps sOps = |
421 | 30 | { |
422 | 30 | s_HashKey, |
423 | 30 | s_MatchEntry, |
424 | 30 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, |
425 | 30 | s_ClearEntry, |
426 | 30 | s_InitEntry |
427 | 30 | }; |
428 | 30 | return &sOps; |
429 | 30 | } nsTHashtable<detail::VoidPtrHashKey>::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::Ops() Line | Count | Source | 416 | 1 | { | 417 | 1 | // If this variable is a global variable, we get strange start-up failures on | 418 | 1 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 1 | // function avoids that problem. | 420 | 1 | static const PLDHashTableOps sOps = | 421 | 1 | { | 422 | 1 | s_HashKey, | 423 | 1 | s_MatchEntry, | 424 | 1 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 1 | s_ClearEntry, | 426 | 1 | s_InitEntry | 427 | 1 | }; | 428 | 1 | return &sOps; | 429 | 1 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::Ops() nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::Ops() Line | Count | Source | 416 | 5 | { | 417 | 5 | // If this variable is a global variable, we get strange start-up failures on | 418 | 5 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 5 | // function avoids that problem. | 420 | 5 | static const PLDHashTableOps sOps = | 421 | 5 | { | 422 | 5 | s_HashKey, | 423 | 5 | s_MatchEntry, | 424 | 5 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 5 | s_ClearEntry, | 426 | 5 | s_InitEntry | 427 | 5 | }; | 428 | 5 | return &sOps; | 429 | 5 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::Ops() Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::Ops() Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::Ops() Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::Ops() nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
nsTHashtable<nsObserverList>::Ops() Line | Count | Source | 416 | 3 | { | 417 | 3 | // If this variable is a global variable, we get strange start-up failures on | 418 | 3 | // WindowsCrtPatch.h (see bug 1166598 comment 20). But putting it inside a | 419 | 3 | // function avoids that problem. | 420 | 3 | static const PLDHashTableOps sOps = | 421 | 3 | { | 422 | 3 | s_HashKey, | 423 | 3 | s_MatchEntry, | 424 | 3 | EntryType::ALLOW_MEMMOVE ? mozilla::detail::FixedSizeEntryMover<sizeof(EntryType)> : s_CopyEntry, | 425 | 3 | s_ClearEntry, | 426 | 3 | s_InitEntry | 427 | 3 | }; | 428 | 3 | return &sOps; | 429 | 3 | } |
|
430 | | |
431 | | // static definitions |
432 | | |
433 | | template<class EntryType> |
434 | | PLDHashNumber |
435 | | nsTHashtable<EntryType>::s_HashKey(const void* aKey) |
436 | 7.50M | { |
437 | 7.50M | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); |
438 | 7.50M | } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::s_HashKey(void const*) nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::s_HashKey(void const*) Line | Count | Source | 436 | 147 | { | 437 | 147 | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); | 438 | 147 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::s_HashKey(void const*) Line | Count | Source | 436 | 3 | { | 437 | 3 | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); | 438 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::s_HashKey(void const*) Line | Count | Source | 436 | 7.50M | { | 437 | 7.50M | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); | 438 | 7.50M | } |
nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::s_HashKey(void const*) Line | Count | Source | 436 | 6 | { | 437 | 6 | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); | 438 | 6 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::s_HashKey(void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::s_HashKey(void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::s_HashKey(void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::s_HashKey(void const*) Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::s_HashKey(void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::s_HashKey(void const*) Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::s_HashKey(void const*) nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::s_HashKey(void const*) Line | Count | Source | 436 | 134 | { | 437 | 134 | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); | 438 | 134 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::s_HashKey(void const*) Line | Count | Source | 436 | 85 | { | 437 | 85 | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); | 438 | 85 | } |
nsTHashtable<nsObserverList>::s_HashKey(void const*) Line | Count | Source | 436 | 368 | { | 437 | 368 | return EntryType::HashKey(static_cast<KeyTypePointer>(aKey)); | 438 | 368 | } |
|
439 | | |
440 | | template<class EntryType> |
441 | | bool |
442 | | nsTHashtable<EntryType>::s_MatchEntry(const PLDHashEntryHdr* aEntry, |
443 | | const void* aKey) |
444 | 7.50M | { |
445 | 7.50M | return ((const EntryType*)aEntry)->KeyEquals( |
446 | 7.50M | static_cast<KeyTypePointer>(aKey)); |
447 | 7.50M | } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::s_MatchEntry(PLDHashEntryHdr const*, void const*) nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Line | Count | Source | 444 | 7.50M | { | 445 | 7.50M | return ((const EntryType*)aEntry)->KeyEquals( | 446 | 7.50M | static_cast<KeyTypePointer>(aKey)); | 447 | 7.50M | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::s_MatchEntry(PLDHashEntryHdr const*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::s_MatchEntry(PLDHashEntryHdr const*, void const*) nsTHashtable<nsObserverList>::s_MatchEntry(PLDHashEntryHdr const*, void const*) Line | Count | Source | 444 | 188 | { | 445 | 188 | return ((const EntryType*)aEntry)->KeyEquals( | 446 | 188 | static_cast<KeyTypePointer>(aKey)); | 447 | 188 | } |
|
448 | | |
449 | | template<class EntryType> |
450 | | void |
451 | | nsTHashtable<EntryType>::s_CopyEntry(PLDHashTable* aTable, |
452 | | const PLDHashEntryHdr* aFrom, |
453 | | PLDHashEntryHdr* aTo) |
454 | 0 | { |
455 | 0 | EntryType* fromEntry = |
456 | 0 | const_cast<EntryType*>(static_cast<const EntryType*>(aFrom)); |
457 | 0 |
|
458 | 0 | new (mozilla::KnownNotNull, aTo) EntryType(std::move(*fromEntry)); |
459 | 0 |
|
460 | 0 | fromEntry->~EntryType(); |
461 | 0 | } Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<mozilla::PseudoElementHashEntry, bool> >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsRefPtrHashKey<mozilla::dom::Animation> >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsISupportsHashKey>::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, RefPtr<mozilla::dom::ChromeMessageBroadcaster> > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsAutoPtr<nsCOMArray<nsMutationReceiver> > > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsINode>, nsAutoPtr<nsTArray<nsAutoAnimationMutationBatch::Entry> > > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsObserverList>::s_CopyEntry(PLDHashTable*, PLDHashEntryHdr const*, PLDHashEntryHdr*) |
462 | | |
463 | | template<class EntryType> |
464 | | void |
465 | | nsTHashtable<EntryType>::s_ClearEntry(PLDHashTable* aTable, |
466 | | PLDHashEntryHdr* aEntry) |
467 | 18 | { |
468 | 18 | static_cast<EntryType*>(aEntry)->~EntryType(); |
469 | 18 | } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Line | Count | Source | 467 | 18 | { | 468 | 18 | static_cast<EntryType*>(aEntry)->~EntryType(); | 469 | 18 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) Unexecuted instantiation: nsTHashtable<nsObserverList>::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*) |
470 | | |
471 | | template<class EntryType> |
472 | | void |
473 | | nsTHashtable<EntryType>::s_InitEntry(PLDHashEntryHdr* aEntry, |
474 | | const void* aKey) |
475 | 346 | { |
476 | 346 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); |
477 | 346 | } Unexecuted instantiation: nsTHashtable<detail::VoidPtrHashKey>::s_InitEntry(PLDHashEntryHdr*, void const*) nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<mozilla::LogModule> > >::s_InitEntry(PLDHashEntryHdr*, void const*) Line | Count | Source | 475 | 75 | { | 476 | 75 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); | 477 | 75 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void>, mozilla::JSHolderInfo*> >::s_InitEntry(PLDHashEntryHdr*, void const*) Line | Count | Source | 475 | 3 | { | 476 | 3 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); | 477 | 3 | } |
nsTHashtable<nsBaseHashtableET<nsFuncPtrHashKey<bool (*)(unsigned int, void*)>, void*> >::s_InitEntry(PLDHashEntryHdr*, void const*) Line | Count | Source | 475 | 18 | { | 476 | 18 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); | 477 | 18 | } |
nsTHashtable<nsBaseHashtableET<nsUint32HashKey, nsAutoPtr<nsTString<char> > > >::s_InitEntry(PLDHashEntryHdr*, void const*) Line | Count | Source | 475 | 6 | { | 476 | 6 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); | 477 | 6 | } |
Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsISupportsHashKey, nsCOMPtr<nsIConsoleListener> > >::s_InitEntry(PLDHashEntryHdr*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsCharPtrHashKey, nsAutoPtr<nsINIParser_internal::INIValue> > >::s_InitEntry(PLDHashEntryHdr*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIVariant> > >::s_InitEntry(PLDHashEntryHdr*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsDepCharHashKey, nsAutoPtr<BloatEntry> > >::s_InitEntry(PLDHashEntryHdr*, void const*) Unexecuted instantiation: nsTHashtable<nsCharPtrHashKey>::s_InitEntry(PLDHashEntryHdr*, void const*) Unexecuted instantiation: nsTHashtable<nsBaseHashtableET<nsPtrHashKey<void const>, nsAutoPtr<SerialNumberRecord> > >::s_InitEntry(PLDHashEntryHdr*, void const*) Unexecuted instantiation: nsTHashtable<IntPtrHashKey>::s_InitEntry(PLDHashEntryHdr*, void const*) nsTHashtable<nsBaseHashtableET<nsRefPtrHashKey<nsIMemoryReporter>, bool> >::s_InitEntry(PLDHashEntryHdr*, void const*) Line | Count | Source | 475 | 52 | { | 476 | 52 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); | 477 | 52 | } |
nsTHashtable<nsBaseHashtableET<nsPtrHashKey<nsIMemoryReporter>, bool> >::s_InitEntry(PLDHashEntryHdr*, void const*) Line | Count | Source | 475 | 33 | { | 476 | 33 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); | 477 | 33 | } |
nsTHashtable<nsObserverList>::s_InitEntry(PLDHashEntryHdr*, void const*) Line | Count | Source | 475 | 159 | { | 476 | 159 | new (mozilla::KnownNotNull, aEntry) EntryType(static_cast<KeyTypePointer>(aKey)); | 477 | 159 | } |
|
478 | | |
479 | | class nsCycleCollectionTraversalCallback; |
480 | | |
481 | | template<class EntryType> |
482 | | inline void |
483 | | ImplCycleCollectionUnlink(nsTHashtable<EntryType>& aField) |
484 | | { |
485 | | aField.Clear(); |
486 | | } |
487 | | |
488 | | template<class EntryType> |
489 | | inline void |
490 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, |
491 | | nsTHashtable<EntryType>& aField, |
492 | | const char* aName, |
493 | | uint32_t aFlags = 0) |
494 | | { |
495 | | for (auto iter = aField.Iter(); !iter.Done(); iter.Next()) { |
496 | | EntryType* entry = iter.Get(); |
497 | | ImplCycleCollectionTraverse(aCallback, *entry, aName, aFlags); |
498 | | } |
499 | | } |
500 | | |
501 | | /** |
502 | | * For nsTHashtable with pointer entries, we can have a template specialization |
503 | | * that layers a typed T* interface on top of a common implementation that |
504 | | * works internally with void pointers. This arrangement saves code size and |
505 | | * might slightly improve performance as well. |
506 | | */ |
507 | | |
508 | | /** |
509 | | * We need a separate entry type class for the inheritance structure of the |
510 | | * nsTHashtable specialization below; nsVoidPtrHashKey is simply typedefed to a |
511 | | * specialization of nsPtrHashKey, and the formulation: |
512 | | * |
513 | | * class nsTHashtable<nsPtrHashKey<T>> : protected nsTHashtable<nsPtrHashKey<const void> |
514 | | * |
515 | | * is not going to turn out very well, since we'd wind up with an nsTHashtable |
516 | | * instantiation that is its own base class. |
517 | | */ |
518 | | namespace detail { |
519 | | |
520 | | class VoidPtrHashKey : public nsPtrHashKey<const void> |
521 | | { |
522 | | typedef nsPtrHashKey<const void> Base; |
523 | | |
524 | | public: |
525 | 0 | explicit VoidPtrHashKey(const void* aKey) : Base(aKey) {} |
526 | | }; |
527 | | |
528 | | } // namespace detail |
529 | | |
530 | | /** |
531 | | * See the main nsTHashtable documentation for descriptions of this class's |
532 | | * methods. |
533 | | */ |
534 | | template<typename T> |
535 | | class nsTHashtable<nsPtrHashKey<T>> : protected nsTHashtable<::detail::VoidPtrHashKey> |
536 | | { |
537 | | typedef nsTHashtable<::detail::VoidPtrHashKey> Base; |
538 | | typedef nsPtrHashKey<T> EntryType; |
539 | | |
540 | | // We play games with reinterpret_cast'ing between these two classes, so |
541 | | // try to ensure that playing said games is reasonable. |
542 | | static_assert(sizeof(nsPtrHashKey<T>) == sizeof(::detail::VoidPtrHashKey), |
543 | | "hash keys must be the same size"); |
544 | | |
545 | | nsTHashtable(const nsTHashtable& aOther) = delete; |
546 | | nsTHashtable& operator=(const nsTHashtable& aOther) = delete; |
547 | | |
548 | | public: |
549 | 3 | nsTHashtable() = default; |
550 | | explicit nsTHashtable(uint32_t aInitLength) |
551 | | : Base(aInitLength) |
552 | | {} |
553 | | |
554 | | ~nsTHashtable() = default; |
555 | | |
556 | | nsTHashtable(nsTHashtable&&) = default; |
557 | | |
558 | | using Base::GetGeneration; |
559 | | using Base::Count; |
560 | | using Base::IsEmpty; |
561 | | using Base::Clear; |
562 | | |
563 | | using Base::ShallowSizeOfExcludingThis; |
564 | | using Base::ShallowSizeOfIncludingThis; |
565 | | |
566 | | #ifdef DEBUG |
567 | | using Base::MarkImmutable; |
568 | | #endif |
569 | | |
570 | | /* Wrapper functions */ |
571 | | EntryType* GetEntry(T* aKey) const |
572 | | { |
573 | | return reinterpret_cast<EntryType*>(Base::GetEntry(aKey)); |
574 | | } |
575 | | |
576 | | bool Contains(T* aKey) const |
577 | | { |
578 | | return Base::Contains(aKey); |
579 | | } |
580 | | |
581 | | EntryType* PutEntry(T* aKey) |
582 | 0 | { |
583 | 0 | return reinterpret_cast<EntryType*>(Base::PutEntry(aKey)); |
584 | 0 | } |
585 | | |
586 | | MOZ_MUST_USE |
587 | | EntryType* PutEntry(T* aKey, const mozilla::fallible_t&) |
588 | | { |
589 | | return reinterpret_cast<EntryType*>( |
590 | | Base::PutEntry(aKey, mozilla::fallible)); |
591 | | } |
592 | | |
593 | | MOZ_MUST_USE |
594 | | bool EnsureInserted(T* aKey, EntryType** aEntry = nullptr) |
595 | | { |
596 | | return Base::EnsureInserted(aKey, reinterpret_cast<::detail::VoidPtrHashKey**>(aEntry)); |
597 | | } |
598 | | |
599 | | void RemoveEntry(T* aKey) |
600 | | { |
601 | | Base::RemoveEntry(aKey); |
602 | | } |
603 | | |
604 | | bool EnsureRemoved(T* aKey) |
605 | | { |
606 | | return Base::EnsureRemoved(aKey); |
607 | | } |
608 | | |
609 | | void RemoveEntry(EntryType* aEntry) |
610 | | { |
611 | | Base::RemoveEntry(reinterpret_cast<::detail::VoidPtrHashKey*>(aEntry)); |
612 | | } |
613 | | |
614 | | void RawRemoveEntry(EntryType* aEntry) |
615 | | { |
616 | | Base::RawRemoveEntry(reinterpret_cast<::detail::VoidPtrHashKey*>(aEntry)); |
617 | | } |
618 | | |
619 | | class Iterator : public Base::Iterator |
620 | | { |
621 | | public: |
622 | | typedef nsTHashtable::Base::Iterator Base; |
623 | | |
624 | 0 | explicit Iterator(nsTHashtable* aTable) : Base(aTable) {} |
625 | | Iterator(Iterator&& aOther) : Base(std::move(aOther)) {} |
626 | | ~Iterator() = default; |
627 | | |
628 | 0 | EntryType* Get() const { return reinterpret_cast<EntryType*>(Base::Get()); } |
629 | | |
630 | | private: |
631 | | Iterator() = delete; |
632 | | Iterator(const Iterator&) = delete; |
633 | | Iterator& operator=(const Iterator&) = delete; |
634 | | Iterator& operator=(Iterator&&) = delete; |
635 | | }; |
636 | | |
637 | 0 | Iterator Iter() { return Iterator(this); } |
638 | | |
639 | | Iterator ConstIter() const |
640 | | { |
641 | | return Iterator(const_cast<nsTHashtable*>(this)); |
642 | | } |
643 | | |
644 | | void SwapElements(nsTHashtable& aOther) |
645 | | { |
646 | | Base::SwapElements(aOther); |
647 | | } |
648 | | }; |
649 | | |
650 | | #endif // nsTHashtable_h__ |