Bug 1691913 - Rename nsClassHashtable::LookupOrAdd to GetOrInsertNew. r=xpcom-reviewers,nika

It should be called "Get" rather than "Lookup" because it returns
UserDataType. "Add" is called "Insert" in the other methods.

Differential Revision: https://phabricator.services.mozilla.com/D105470
This commit is contained in:
Simon Giesecke 2021-02-22 12:07:47 +00:00
parent 901cbda9f5
commit c5f7800f35
38 changed files with 61 additions and 57 deletions

View File

@ -428,7 +428,7 @@ void NotificationController::ScheduleChildDocBinding(DocAccessible* aDocument) {
void NotificationController::ScheduleContentInsertion(
LocalAccessible* aContainer, nsTArray<nsCOMPtr<nsIContent>>& aInsertions) {
if (!aInsertions.IsEmpty()) {
mContentInsertions.LookupOrAdd(aContainer)->AppendElements(aInsertions);
mContentInsertions.GetOrInsertNew(aContainer)->AppendElements(aInsertions);
ScheduleProcessing();
}
}
@ -741,7 +741,7 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
mDocument->AccessibleOrTrueContainer(containerNode, true);
if (container) {
nsTArray<nsCOMPtr<nsIContent>>* list =
mContentInsertions.LookupOrAdd(container);
mContentInsertions.GetOrInsertNew(container);
list->AppendElement(textNode);
}
}

View File

@ -2323,7 +2323,8 @@ void DocAccessible::DoARIAOwnsRelocation(LocalAccessible* aOwner) {
logging::TreeInfo("aria owns relocation", logging::eVerbose, aOwner);
#endif
nsTArray<RefPtr<LocalAccessible>>* owned = mARIAOwnsHash.LookupOrAdd(aOwner);
nsTArray<RefPtr<LocalAccessible>>* owned =
mARIAOwnsHash.GetOrInsertNew(aOwner);
IDRefsIterator iter(this, aOwner->Elm(), nsGkAtoms::aria_owns);
uint32_t idx = 0;
@ -2420,7 +2421,7 @@ void DocAccessible::DoARIAOwnsRelocation(LocalAccessible* aOwner) {
if (MoveChild(child, aOwner, insertIdx)) {
child->SetRelocated(true);
MOZ_ASSERT(owned == mARIAOwnsHash.Get(aOwner));
owned = mARIAOwnsHash.LookupOrAdd(aOwner);
owned = mARIAOwnsHash.GetOrInsertNew(aOwner);
owned->InsertElementAt(idx, child);
idx++;
}

View File

@ -477,7 +477,7 @@ void nsChromeRegistryChrome::ManifestContent(ManifestProcessingContext& cx,
}
nsDependentCString packageName(package);
PackageEntry* entry = mPackagesHash.LookupOrAdd(packageName);
PackageEntry* entry = mPackagesHash.GetOrInsertNew(packageName);
entry->baseURI = resolved;
entry->flags = flags;
@ -514,7 +514,7 @@ void nsChromeRegistryChrome::ManifestLocale(ManifestProcessingContext& cx,
}
nsDependentCString packageName(package);
PackageEntry* entry = mPackagesHash.LookupOrAdd(packageName);
PackageEntry* entry = mPackagesHash.GetOrInsertNew(packageName);
entry->locales.SetBase(nsDependentCString(provider), resolved);
if (mDynamicRegistration) {
@ -559,7 +559,7 @@ void nsChromeRegistryChrome::ManifestSkin(ManifestProcessingContext& cx,
}
nsDependentCString packageName(package);
PackageEntry* entry = mPackagesHash.LookupOrAdd(packageName);
PackageEntry* entry = mPackagesHash.GetOrInsertNew(packageName);
entry->skins.SetBase(nsDependentCString(provider), resolved);
if (mDynamicRegistration) {

View File

@ -1021,7 +1021,7 @@ static void GetKeyframeListFromPropertyIndexedKeyframe(
// For single-valued lists, the single value should be added to a
// keyframe with offset 1.
double offset = n ? i++ / double(n) : 1;
Keyframe* keyframe = processedKeyframes.LookupOrAdd(offset);
Keyframe* keyframe = processedKeyframes.GetOrInsertNew(offset);
if (keyframe->mPropertyValues.IsEmpty()) {
keyframe->mComputedOffset = offset;
}

View File

@ -352,7 +352,7 @@ CustomElementDefinition* CustomElementRegistry::LookupCustomElementDefinition(
mElementCreationCallbacks.Get(aTypeAtom, getter_AddRefs(callback));
if (callback) {
mElementCreationCallbacks.Remove(aTypeAtom);
mElementCreationCallbacksUpgradeCandidatesMap.LookupOrAdd(aTypeAtom);
mElementCreationCallbacksUpgradeCandidatesMap.GetOrInsertNew(aTypeAtom);
RefPtr<Runnable> runnable =
new RunCustomElementCreationCallback(this, aTypeAtom, callback);
nsContentUtils::AddScriptRunner(runnable.forget());
@ -409,7 +409,7 @@ void CustomElementRegistry::RegisterUnresolvedElement(Element* aElement,
}
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* unresolved =
mCandidatesMap.LookupOrAdd(typeName);
mCandidatesMap.GetOrInsertNew(typeName);
nsWeakPtr elem = do_GetWeakReference(aElement);
unresolved->PutEntry(elem);
}

View File

@ -195,7 +195,7 @@ void ShadowRoot::AddSlot(HTMLSlotElement* aSlot) {
nsAutoString name;
aSlot->GetName(name);
SlotArray& currentSlots = *mSlotMap.LookupOrAdd(name);
SlotArray& currentSlots = *mSlotMap.GetOrInsertNew(name);
size_t index = currentSlots.Insert(*aSlot);
if (index != 0) {

View File

@ -815,7 +815,7 @@ class nsAutoAnimationMutationBatch {
}
Entry* AddEntry(mozilla::dom::Animation* aAnimation, nsINode* aTarget) {
EntryArray* entries = sCurrentBatch->mEntryTable.LookupOrAdd(aTarget);
EntryArray* entries = sCurrentBatch->mEntryTable.GetOrInsertNew(aTarget);
if (entries->IsEmpty()) {
sCurrentBatch->mBatchTargets.AppendElement(aTarget);
}

View File

@ -7918,7 +7918,7 @@ uint64_t ConnectionPool::Start(
for (const nsString& objectStoreName : aObjectStoreNames) {
TransactionInfoPair* blockInfo =
blockingTransactions.LookupOrAdd(objectStoreName);
blockingTransactions.GetOrInsertNew(objectStoreName);
// Mark what we are blocking on.
if (const auto maybeBlockingRead = blockInfo->mLastBlockingReads) {
@ -12555,7 +12555,7 @@ nsresult QuotaClient::AsyncDeleteFile(FileManager* aFileManager,
DeleteTimerCallback, this, kDeleteTimeoutMs, nsITimer::TYPE_ONE_SHOT,
"dom::indexeddb::QuotaClient::AsyncDeleteFile"));
mPendingDeleteInfos.LookupOrAdd(aFileManager)->AppendElement(aFileId);
mPendingDeleteInfos.GetOrInsertNew(aFileManager)->AppendElement(aFileId);
return NS_OK;
}

View File

@ -697,7 +697,7 @@ void IndexedDatabaseManager::AddFileManager(
NS_ASSERTION(aFileManager, "Null file manager!");
const auto& origin = aFileManager->Origin();
mFileManagerInfos.LookupOrAdd(origin)->AddFileManager(
mFileManagerInfos.GetOrInsertNew(origin)->AddFileManager(
std::move(aFileManager));
}

View File

@ -1535,7 +1535,7 @@ mozilla::ipc::IPCResult BrowserChild::RecvRealMouseMoveEvent(
const uint64_t& aInputBlockId) {
if (mCoalesceMouseMoveEvents && mCoalescedMouseEventFlusher) {
CoalescedMouseData* data =
mCoalescedMouseData.LookupOrAdd(aEvent.pointerId);
mCoalescedMouseData.GetOrInsertNew(aEvent.pointerId);
MOZ_ASSERT(data);
if (data->CanCoalesce(aEvent, aGuid, aInputBlockId)) {
data->Coalesce(aEvent, aGuid, aInputBlockId);

View File

@ -3326,7 +3326,7 @@ nsresult ContentChild::AsyncOpenAnonymousTemporaryFile(
// Remember the association with the callback.
MOZ_ASSERT(!mPendingAnonymousTemporaryFiles.Get(newID));
mPendingAnonymousTemporaryFiles.LookupOrAdd(newID, aCallback);
mPendingAnonymousTemporaryFiles.GetOrInsertNew(newID, aCallback);
return NS_OK;
}

View File

@ -732,7 +732,7 @@ uint32_t ContentParent::GetPoolSize(const nsACString& aContentProcessType) {
new nsClassHashtable<nsCStringHashKey, nsTArray<ContentParent*>>;
}
return *sBrowserContentParents->LookupOrAdd(aContentProcessType);
return *sBrowserContentParents->GetOrInsertNew(aContentProcessType);
}
const nsDependentCSubstring RemoteTypePrefix(

View File

@ -397,7 +397,7 @@ void WritableSharedMap::Set(JSContext* aCx, const nsACString& aName,
return;
}
Entry* entry = mEntries.LookupOrAdd(aName, *this, aName);
Entry* entry = mEntries.GetOrInsertNew(aName, *this, aName);
entry->TakeData(std::move(holder));
KeyChanged(aName);

View File

@ -92,7 +92,7 @@ RefPtr<GenericPromise> AudioStreamTrack::SetAudioOutputDevice(
}
// We are setting a non-default output device.
UniquePtr<CrossGraphPort>& crossGraphPtr = *mCrossGraphs.LookupOrAdd(key);
UniquePtr<CrossGraphPort>& crossGraphPtr = *mCrossGraphs.GetOrInsertNew(key);
if (crossGraphPtr) {
// This key already has a non-default output device set. Destroy it.
crossGraphPtr->Destroy();

View File

@ -44,7 +44,7 @@ DDLifetime& DDLifetimes::CreateLifetime(
if (--sTag > 0) {
sTag = -1;
}
LifetimesForObject* lifetimes = mLifetimes.LookupOrAdd(aObject, 1);
LifetimesForObject* lifetimes = mLifetimes.GetOrInsertNew(aObject, 1);
DDLifetime& lifetime = *lifetimes->AppendElement(
DDLifetime(aObject, aIndex, aConstructionTimeStamp, sTag));
return lifetime;

View File

@ -81,7 +81,7 @@ void MIDIPlatformService::QueueMessages(const nsAString& aId,
::mozilla::ipc::AssertIsOnBackgroundThread();
{
MutexAutoLock lock(mMessageQueueMutex);
MIDIMessageQueue* msgQueue = mMessageQueues.LookupOrAdd(aId);
MIDIMessageQueue* msgQueue = mMessageQueues.GetOrInsertNew(aId);
msgQueue->Add(aMsgs);
ScheduleSend(aId);
}

View File

@ -70,7 +70,7 @@ WindowsDllInterceptor* FunctionHook::GetDllInterceptorFor(
"Non-ASCII module names are not supported");
NS_ConvertASCIItoUTF16 moduleName(aModuleName);
WindowsDllInterceptor* ret = sDllInterceptorCache->LookupOrAdd(moduleName);
WindowsDllInterceptor* ret = sDllInterceptorCache->GetOrInsertNew(moduleName);
MOZ_ASSERT(ret);
ret->Init(moduleName.get());
return ret;

View File

@ -99,7 +99,7 @@ nsAutoCString LocalStorageManager::CreateOrigin(
LocalStorageCache* LocalStorageManager::GetCache(
const nsACString& aOriginSuffix, const nsACString& aOriginNoSuffix) {
CacheOriginHashtable* table = mCaches.LookupOrAdd(aOriginSuffix);
CacheOriginHashtable* table = mCaches.GetOrInsertNew(aOriginSuffix);
LocalStorageCacheHashKey* entry = table->GetEntry(aOriginNoSuffix);
if (!entry) {
return nullptr;
@ -131,7 +131,7 @@ already_AddRefed<StorageUsage> LocalStorageManager::GetOriginUsage(
already_AddRefed<LocalStorageCache> LocalStorageManager::PutCache(
const nsACString& aOriginSuffix, const nsACString& aOriginNoSuffix,
const nsACString& aQuotaKey, nsIPrincipal* aPrincipal) {
CacheOriginHashtable* table = mCaches.LookupOrAdd(aOriginSuffix);
CacheOriginHashtable* table = mCaches.GetOrInsertNew(aOriginSuffix);
LocalStorageCacheHashKey* entry = table->PutEntry(aOriginNoSuffix);
RefPtr<LocalStorageCache> cache = entry->cache();
@ -147,7 +147,7 @@ void LocalStorageManager::DropCache(LocalStorageCache* aCache) {
"down?");
}
CacheOriginHashtable* table = mCaches.LookupOrAdd(aCache->OriginSuffix());
CacheOriginHashtable* table = mCaches.GetOrInsertNew(aCache->OriginSuffix());
table->RemoveEntry(aCache->OriginNoSuffix());
}

View File

@ -29,7 +29,7 @@ void TextureSourceProvider::ReadUnlockTextures() {
if (actor) {
base::ProcessId pid = actor->OtherPid();
nsTArray<uint64_t>* textureIds =
texturesIdsToUnlockByPid.LookupOrAdd(pid);
texturesIdsToUnlockByPid.GetOrInsertNew(pid);
textureIds->AppendElement(TextureHost::GetTextureSerial(actor));
}
} else {

View File

@ -2266,7 +2266,7 @@ void CompositorOGL::TryUnlockTextures() {
if (actor) {
base::ProcessId pid = actor->OtherPid();
nsTArray<uint64_t>* textureIds =
texturesIdsToUnlockByPid.LookupOrAdd(pid);
texturesIdsToUnlockByPid.GetOrInsertNew(pid);
textureIds->AppendElement(TextureHost::GetTextureSerial(actor));
}
}

View File

@ -983,7 +983,7 @@ void WebRenderBridgeParent::AddPendingScrollPayload(
CompositionPayload& aPayload, const VsyncId& aCompositeStartId) {
auto pendingScrollPayloads = mPendingScrollPayloads.Lock();
nsTArray<CompositionPayload>* payloads =
pendingScrollPayloads->LookupOrAdd(aCompositeStartId.mId);
pendingScrollPayloads->GetOrInsertNew(aCompositeStartId.mId);
payloads->AppendElement(aPayload);
}

View File

@ -1427,7 +1427,7 @@ void gfxDWriteFontList::ReadFaceNamesForFamily(
for (const auto& alias : otherFamilyNames) {
nsAutoCString key(alias);
ToLowerCase(key);
auto aliasData = mAliasTable.LookupOrAdd(key);
auto aliasData = mAliasTable.GetOrInsertNew(key);
aliasData->InitFromFamily(aFamily, familyName);
aliasData->mFaces.AppendElement(facePtrs[i]);
}

View File

@ -1079,7 +1079,7 @@ void gfxMacPlatformFontList::InitAliasesForSingleFaceList() {
MOZ_ASSERT(false, "single-face family already known");
break;
}
auto aliasData = mAliasTable.LookupOrAdd(key);
auto aliasData = mAliasTable.GetOrInsertNew(key);
// The "alias" here isn't based on an existing family, so we don't call
// aliasData->InitFromFamily(); the various flags are left as defaults.
aliasData->mFaces.AppendElement(facePtrs[i]);
@ -1885,7 +1885,7 @@ void gfxMacPlatformFontList::ReadFaceNamesForFamily(fontlist::Family* aFamily,
for (const auto& alias : otherFamilyNames) {
nsAutoCString key;
GenerateFontListKey(alias, key);
auto aliasData = mAliasTable.LookupOrAdd(key);
auto aliasData = mAliasTable.GetOrInsertNew(key);
aliasData->InitFromFamily(aFamily, canonicalName);
aliasData->mFaces.AppendElement(facePtrs[i]);
}

View File

@ -795,7 +795,7 @@ void ScriptPreloader::NoteScript(const nsCString& url,
}
auto script =
mScripts.LookupOrAdd(cachePath, *this, url, cachePath, jsscript);
mScripts.GetOrInsertNew(cachePath, *this, url, cachePath, jsscript);
if (isRunOnce) {
script->mIsRunOnce = true;
}
@ -824,7 +824,8 @@ void ScriptPreloader::NoteScript(const nsCString& url,
return;
}
auto script = mScripts.LookupOrAdd(cachePath, *this, url, cachePath, nullptr);
auto script =
mScripts.GetOrInsertNew(cachePath, *this, url, cachePath, nullptr);
if (!script->HasRange()) {
MOZ_ASSERT(!script->HasArray());

View File

@ -306,7 +306,7 @@ Result<Ok, nsresult> URLPreloader::ReadCache(
LOG(Debug, "Cached file: %s %s", key.TypeString(), key.mPath.get());
auto entry = mCachedURLs.LookupOrAdd(key, key);
auto entry = mCachedURLs.GetOrInsertNew(key, key);
entry->mResultCode = NS_ERROR_NOT_INITIALIZED;
pendingURLs.insertBack(entry);
@ -458,7 +458,7 @@ Result<nsCString, nsresult> URLPreloader::ReadInternal(const CacheKey& key,
return entry.Read();
}
auto entry = mCachedURLs.LookupOrAdd(key, key);
auto entry = mCachedURLs.GetOrInsertNew(key, key);
entry->UpdateUsedTime();

View File

@ -2917,7 +2917,8 @@ ServoElementSnapshot& RestyleManager::SnapshotFor(Element& aElement) {
MOZ_ASSERT(aElement.HasServoData());
MOZ_ASSERT(!aElement.HasFlag(ELEMENT_HANDLED_SNAPSHOT));
ServoElementSnapshot* snapshot = mSnapshots.LookupOrAdd(&aElement, aElement);
ServoElementSnapshot* snapshot =
mSnapshots.GetOrInsertNew(&aElement, aElement);
aElement.SetFlags(ELEMENT_HAS_SNAPSHOT);
// Now that we have a snapshot, make sure a restyle is triggered.

View File

@ -958,7 +958,8 @@ class nsDisplayListBuilder {
return;
}
nsTArray<ThemeGeometry>* geometries = mThemeGeometries.LookupOrAdd(aItem);
nsTArray<ThemeGeometry>* geometries =
mThemeGeometries.GetOrInsertNew(aItem);
geometries->AppendElement(ThemeGeometry(aWidgetType, aRect));
}

View File

@ -269,7 +269,7 @@ void CookieServiceChild::RecordDocumentCookie(Cookie* aCookie,
mCookiesMap.Get(key, &cookiesList);
if (!cookiesList) {
cookiesList = mCookiesMap.LookupOrAdd(key);
cookiesList = mCookiesMap.GetOrInsertNew(key);
}
for (uint32_t i = 0; i < cookiesList->Length(); i++) {
Cookie* cookie = cookiesList->ElementAt(i);

View File

@ -2601,7 +2601,7 @@ void nsHttpConnectionMgr::AddActiveTransaction(nsHttpTransaction* aTrans) {
bool throttled = aTrans->EligibleForThrottling();
nsTArray<RefPtr<nsHttpTransaction>>* transactions =
mActiveTransactions[throttled].LookupOrAdd(tabId);
mActiveTransactions[throttled].GetOrInsertNew(tabId);
MOZ_ASSERT(!transactions->Contains(aTrans));

View File

@ -356,7 +356,7 @@ typedef nsClassHashtable<nsUint32HashKey, CachedFullHashResponse>
template <class T>
void CopyClassHashTable(const T& aSource, T& aDestination) {
for (auto iter = aSource.ConstIter(); !iter.Done(); iter.Next()) {
auto value = aDestination.LookupOrAdd(iter.Key());
auto value = aDestination.GetOrInsertNew(iter.Key());
*value = *(iter.Data());
}
}

View File

@ -211,7 +211,7 @@ void TableUpdateV4::SetSHA256(const std::string& aSHA256) {
nsresult TableUpdateV4::NewFullHashResponse(
const Prefix& aPrefix, const CachedFullHashResponse& aResponse) {
CachedFullHashResponse* response =
mFullHashResponseMap.LookupOrAdd(aPrefix.ToUint32());
mFullHashResponseMap.GetOrInsertNew(aPrefix.ToUint32());
if (!response) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -933,7 +933,7 @@ void LookupCacheV2::AddGethashResultToCache(
reinterpret_cast<const char*>(add.CompleteHash().buf), COMPLETE_SIZE);
CachedFullHashResponse* response =
mFullHashCache.LookupOrAdd(add.ToUint32());
mFullHashCache.GetOrInsertNew(add.ToUint32());
response->negativeCacheExpirySec = defaultExpirySec;
FullHashExpiryCache& fullHashes = response->fullHashes;
@ -942,7 +942,7 @@ void LookupCacheV2::AddGethashResultToCache(
for (const Prefix& prefix : aMissPrefixes) {
CachedFullHashResponse* response =
mFullHashCache.LookupOrAdd(prefix.ToUint32());
mFullHashCache.GetOrInsertNew(prefix.ToUint32());
response->negativeCacheExpirySec = defaultExpirySec;
}

View File

@ -274,7 +274,7 @@ static nsresult AppendPrefixToMap(PrefixStringMap& prefixes,
return NS_OK;
}
nsCString* prefixString = prefixes.LookupOrAdd(len);
nsCString* prefixString = prefixes.GetOrInsertNew(len);
if (!prefixString->Append(prefix, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -523,7 +523,7 @@ VLPrefixSet::VLPrefixSet(const PrefixStringMap& aMap) : mCount(0) {
void VLPrefixSet::Merge(PrefixStringMap& aPrefixMap) {
for (auto iter = mMap.ConstIter(); !iter.Done(); iter.Next()) {
nsCString* prefixString = aPrefixMap.LookupOrAdd(iter.Key());
nsCString* prefixString = aPrefixMap.GetOrInsertNew(iter.Key());
PrefixString* str = iter.UserData();
nsAutoCString remainingString;

View File

@ -118,7 +118,7 @@ nsresult PrefixArrayToPrefixStringMap(const _PrefixArray& aPrefixArray,
// all prefixes of that length.
nsClassHashtable<nsUint32HashKey, _PrefixArray> table;
for (const auto& prefix : aPrefixArray) {
_PrefixArray* array = table.LookupOrAdd(prefix.Length());
_PrefixArray* array = table.GetOrInsertNew(prefix.Length());
array->AppendElement(prefix);
}

View File

@ -46,7 +46,7 @@ static void SetupCacheEntry(LookupCacheV4* aLookupCache,
Prefix prefix;
prefix.FromPlaintext(aCompletion);
CachedFullHashResponse* response = map.LookupOrAdd(prefix.ToUint32());
CachedFullHashResponse* response = map.GetOrInsertNew(prefix.ToUint32());
response->negativeCacheExpirySec =
aNegExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC;
@ -255,7 +255,7 @@ TEST(UrlClassifierCaching, NegativeCacheExpireV4)
nsCOMPtr<nsICryptoHash> cryptoHash =
do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID);
prefix.FromPlaintext(NEG_CACHE_EXPIRED_URL);
CachedFullHashResponse* response = map.LookupOrAdd(prefix.ToUint32());
CachedFullHashResponse* response = map.GetOrInsertNew(prefix.ToUint32());
response->negativeCacheExpirySec = EXPIRED_TIME_SEC;

View File

@ -132,7 +132,7 @@ bool VibrancyManager::UpdateVibrantRegion(VibrancyType aType,
if (aRegion.IsEmpty()) {
return mVibrantRegions.Remove(uint32_t(aType));
}
auto& vr = *mVibrantRegions.LookupOrAdd(uint32_t(aType));
auto& vr = *mVibrantRegions.GetOrInsertNew(uint32_t(aType));
return vr.UpdateRegion(aRegion, mCoordinateConverter, mContainerView, ^() {
return this->CreateEffectView(aType);
});

View File

@ -56,7 +56,7 @@ class nsClassHashtable : public nsBaseHashtable<KeyClass, mozilla::UniquePtr<T>,
* KeyClass will be created (using the arguments provided) and then returned.
*/
template <typename... Args>
UserDataType LookupOrAdd(KeyType aKey, Args&&... aConstructionArgs);
UserDataType GetOrInsertNew(KeyType aKey, Args&&... aConstructionArgs);
/**
* @copydoc nsBaseHashtable::Get
@ -92,8 +92,8 @@ inline void ImplCycleCollectionTraverse(
template <class KeyClass, class T>
template <typename... Args>
T* nsClassHashtable<KeyClass, T>::LookupOrAdd(KeyType aKey,
Args&&... aConstructionArgs) {
T* nsClassHashtable<KeyClass, T>::GetOrInsertNew(KeyType aKey,
Args&&... aConstructionArgs) {
return this
->GetOrInsertWith(std::move(aKey),
[&] {

View File

@ -1442,7 +1442,7 @@ TEST(Hashtables, ClassHashtable_WithEntryHandle)
ASSERT_TRUE(0 == EntToUniClass.Count());
}
TEST(Hashtables, ClassHashtable_LookupOrAdd_Present)
TEST(Hashtables, ClassHashtable_GetOrInsertNew_Present)
{
nsClassHashtable<nsCStringHashKey, TestUniChar> EntToUniClass(ENTITY_COUNT);
@ -1451,16 +1451,16 @@ TEST(Hashtables, ClassHashtable_LookupOrAdd_Present)
mozilla::MakeUnique<TestUniCharDerived>(entity.mUnicode));
}
auto* entry = EntToUniClass.LookupOrAdd("uml"_ns, 42);
auto* entry = EntToUniClass.GetOrInsertNew("uml"_ns, 42);
EXPECT_EQ(168u, entry->GetChar());
}
TEST(Hashtables, ClassHashtable_LookupOrAdd_NotPresent)
TEST(Hashtables, ClassHashtable_GetOrInsertNew_NotPresent)
{
nsClassHashtable<nsCStringHashKey, TestUniChar> EntToUniClass(ENTITY_COUNT);
// This is going to insert a TestUniChar.
auto* entry = EntToUniClass.LookupOrAdd("uml"_ns, 42);
auto* entry = EntToUniClass.GetOrInsertNew("uml"_ns, 42);
EXPECT_EQ(42u, entry->GetChar());
}