mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1041822 - Add LookupOrAdd to nsClassHashtable. r=bsmedberg
This commit is contained in:
parent
6983488b27
commit
164fd2b0e8
@ -35,6 +35,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up aKey in the hash table. If it doesn't exist a new object of
|
||||
* KeyClass will be created (using its default constructor) and then
|
||||
* returned.
|
||||
*/
|
||||
UserDataType LookupOrAdd(KeyType aKey);
|
||||
|
||||
/**
|
||||
* @copydoc nsBaseHashtable::Get
|
||||
* @param aData if the key doesn't exist, pData will be set to nullptr.
|
||||
@ -65,6 +72,17 @@ public:
|
||||
// nsClassHashtable definitions
|
||||
//
|
||||
|
||||
template<class KeyClass, class T>
|
||||
T*
|
||||
nsClassHashtable<KeyClass, T>::LookupOrAdd(KeyType aKey)
|
||||
{
|
||||
typename base_type::EntryType* ent = this->PutEntry(aKey);
|
||||
if (!ent->mData) {
|
||||
ent->mData = new T();
|
||||
}
|
||||
return ent->mData;
|
||||
}
|
||||
|
||||
template<class KeyClass, class T>
|
||||
bool
|
||||
nsClassHashtable<KeyClass, T>::Get(KeyType aKey, T** aRetVal) const
|
||||
|
Loading…
Reference in New Issue
Block a user