From 4f75368dcbfdb9cb088834e5ca7fff28b4a84a27 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Fri, 26 Feb 2021 09:11:45 +0000 Subject: [PATCH] Bug 1691913 - Rename nsBaseHashtable::GetOrInsert(With) to LookupOrInsert(With). r=xpcom-reviewers,necko-reviewers,jgilbert,dragana,nika The functions should be called "Lookup" rather than "Get" because they return a DataType& (rather than UserDataType). Differential Revision: https://phabricator.services.mozilla.com/D105472 --- accessible/base/NotificationController.cpp | 2 +- accessible/generic/DocAccessible-inl.h | 7 ++-- docshell/base/BrowsingContextGroup.cpp | 7 ++-- docshell/base/WindowContext.cpp | 2 +- dom/animation/EffectCompositor.cpp | 2 +- dom/base/Document.cpp | 2 +- dom/base/Document.h | 2 +- dom/base/DocumentOrShadowRoot.cpp | 5 ++- dom/base/Element.cpp | 2 +- dom/base/EventSourceEventService.cpp | 4 +- dom/base/ResizeObserver.cpp | 2 +- dom/base/nsDOMAttributeMap.cpp | 2 +- dom/base/nsDOMMutationObserver.cpp | 4 +- dom/base/nsFrameMessageManager.cpp | 4 +- dom/base/nsGlobalWindowInner.cpp | 2 +- .../BroadcastChannelService.cpp | 2 +- dom/clients/manager/ClientManagerService.cpp | 2 +- dom/commandhandler/nsCommandManager.cpp | 5 ++- dom/events/EventListenerService.cpp | 2 +- dom/events/EventStateManager.cpp | 4 +- dom/filehandle/ActorsParent.cpp | 2 +- dom/html/HTMLAllCollection.cpp | 13 +++--- dom/html/HTMLFormElement.cpp | 2 +- dom/indexedDB/ActorsParent.cpp | 12 +++--- dom/ipc/WindowGlobalParent.cpp | 2 +- dom/localstorage/ActorsParent.cpp | 4 +- dom/media/MediaManager.cpp | 2 +- dom/media/MediaTrackGraph.cpp | 2 +- dom/media/gmp/GMPMemoryStorage.cpp | 8 ++-- dom/media/ogg/OggCodecState.cpp | 2 +- dom/payments/PaymentRequestManager.cpp | 2 +- dom/presentation/PresentationServiceBase.h | 16 +++---- dom/quota/ActorsParent.cpp | 31 +++++++------- dom/serviceworkers/ServiceWorkerManager.cpp | 4 +- dom/storage/SessionStorageManager.cpp | 4 +- dom/storage/StorageIPC.cpp | 2 +- dom/workers/RuntimeService.cpp | 4 +- dom/xul/nsXULPrototypeCache.cpp | 2 +- gfx/gl/GLContextProviderEGL.cpp | 4 +- gfx/layers/Layers.cpp | 2 +- gfx/layers/wr/WebRenderCommandBuilder.h | 2 +- gfx/thebes/gfxFT2FontBase.cpp | 2 +- gfx/thebes/gfxFcPlatformFontList.cpp | 27 ++++++------ gfx/thebes/gfxPlatformFontList.cpp | 3 +- intl/locale/DateTimeFormat.cpp | 2 +- ipc/glue/MessageChannel.cpp | 4 +- layout/base/PresShell.cpp | 20 ++++----- layout/base/nsCounterManager.cpp | 3 +- layout/base/nsRefreshDriver.cpp | 3 +- layout/painting/RetainedDisplayListBuilder.h | 2 +- layout/painting/nsDisplayList.cpp | 2 +- layout/printing/nsPrintJob.cpp | 2 +- layout/style/FontFaceSet.cpp | 2 +- layout/style/ImageLoader.cpp | 16 +++---- layout/style/ShadowParts.cpp | 3 +- layout/style/SharedStyleSheetCache.cpp | 4 +- modules/libpref/Preferences.cpp | 2 +- netwerk/cache2/CacheFile.cpp | 2 +- netwerk/cache2/CacheStorageService.cpp | 2 +- netwerk/dns/ChildDNSService.cpp | 2 +- netwerk/dns/DNSPacket.cpp | 2 +- netwerk/dns/GetAddrInfo.cpp | 2 +- netwerk/dns/nsDNSService2.cpp | 4 +- netwerk/dns/nsHostResolver.cpp | 4 +- .../protocol/http/PendingTransactionQueue.cpp | 2 +- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 6 +-- .../websocket/WebSocketEventService.cpp | 2 +- .../streamconv/nsStreamConverterService.cpp | 4 +- .../TemporaryAccessGrantObserver.cpp | 2 +- .../filewatcher/NativeFileWatcherWin.cpp | 8 ++-- .../components/telemetry/core/Stopwatch.cpp | 2 +- .../telemetry/core/TelemetryEvent.cpp | 4 +- .../telemetry/core/TelemetryOrigin.cpp | 8 ++-- .../telemetry/core/TelemetryScalar.cpp | 14 +++---- .../streaming/GeckoViewStreamingTelemetry.cpp | 4 +- toolkit/xre/UntrustedModulesData.cpp | 2 +- widget/android/EventDispatcher.cpp | 3 +- widget/gtk/WakeLockListener.cpp | 2 +- xpcom/base/Logging.cpp | 10 ++--- xpcom/components/nsComponentManager.cpp | 2 +- xpcom/ds/nsBaseHashtable.h | 8 ++-- xpcom/ds/nsClassHashtable.h | 10 ++--- xpcom/tests/gtest/TestHashtables.cpp | 42 +++++++++---------- 83 files changed, 225 insertions(+), 211 deletions(-) diff --git a/accessible/base/NotificationController.cpp b/accessible/base/NotificationController.cpp index fb147098f1c7a..ce541ec710b51 100644 --- a/accessible/base/NotificationController.cpp +++ b/accessible/base/NotificationController.cpp @@ -532,7 +532,7 @@ void NotificationController::ProcessMutationEvents() { } LocalAccessible* parent = event->GetAccessible()->LocalParent(); - showEvents.GetOrInsert(parent).AppendElement(event); + showEvents.LookupOrInsert(parent).AppendElement(event); } // We need to fire show events for the children of an accessible in the order diff --git a/accessible/generic/DocAccessible-inl.h b/accessible/generic/DocAccessible-inl.h index 93f4df6a5f09f..ac707b3bd0add 100644 --- a/accessible/generic/DocAccessible-inl.h +++ b/accessible/generic/DocAccessible-inl.h @@ -165,12 +165,13 @@ inline DocAccessible::AttrRelProviders* DocAccessible::GetOrCreateRelProviders( aElement->GetUncomposedDocOrConnectedShadowRoot(); DependentIDsHashtable* hash = mDependentIDsHashes - .GetOrInsertWith(docOrShadowRoot, - [] { return MakeUnique(); }) + .LookupOrInsertWith( + docOrShadowRoot, + [] { return MakeUnique(); }) .get(); return hash - ->GetOrInsertWith(aID, [] { return MakeUnique(); }) + ->LookupOrInsertWith(aID, [] { return MakeUnique(); }) .get(); } diff --git a/docshell/base/BrowsingContextGroup.cpp b/docshell/base/BrowsingContextGroup.cpp index 9950235f8be25..644b9f58194f5 100644 --- a/docshell/base/BrowsingContextGroup.cpp +++ b/docshell/base/BrowsingContextGroup.cpp @@ -34,8 +34,9 @@ already_AddRefed BrowsingContextGroup::GetOrCreate( ClearOnShutdown(&sBrowsingContextGroups); } - RefPtr group = sBrowsingContextGroups->GetOrInsertWith( - aId, [&aId] { return do_AddRef(new BrowsingContextGroup(aId)); }); + RefPtr group = + sBrowsingContextGroups->LookupOrInsertWith( + aId, [&aId] { return do_AddRef(new BrowsingContextGroup(aId)); }); return group.forget(); } @@ -403,7 +404,7 @@ already_AddRefed BrowsingContextGroup::AddDocument( const nsACString& aKey, Document* aDocument) { MOZ_ASSERT(NS_IsMainThread()); - RefPtr& docGroup = mDocGroups.GetOrInsertWith( + RefPtr& docGroup = mDocGroups.LookupOrInsertWith( aKey, [&] { return DocGroup::Create(this, aKey); }); docGroup->AddDocument(aDocument); diff --git a/docshell/base/WindowContext.cpp b/docshell/base/WindowContext.cpp index dfc19f155a39d..47cae72eac2d4 100644 --- a/docshell/base/WindowContext.cpp +++ b/docshell/base/WindowContext.cpp @@ -352,7 +352,7 @@ void WindowContext::Init() { gWindowContexts = new WindowContextByIdMap(); ClearOnShutdown(&gWindowContexts); } - auto& entry = gWindowContexts->GetOrInsert(mInnerWindowId); + auto& entry = gWindowContexts->LookupOrInsert(mInnerWindowId); MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowContext for ID!"); entry = this; diff --git a/dom/animation/EffectCompositor.cpp b/dom/animation/EffectCompositor.cpp index 737c5c1b1c026..5de3b9063b67c 100644 --- a/dom/animation/EffectCompositor.cpp +++ b/dom/animation/EffectCompositor.cpp @@ -240,7 +240,7 @@ void EffectCompositor::RequestRestyle(dom::Element* aElement, auto& elementsToRestyle = mElementsToRestyle[aCascadeLevel]; PseudoElementHashEntry::KeyType key = {aElement, aPseudoType}; - bool& restyleEntry = elementsToRestyle.GetOrInsert(key, false); + bool& restyleEntry = elementsToRestyle.LookupOrInsert(key, false); if (aRestyleType == RestyleType::Throttled) { mPresContext->PresShell()->SetNeedThrottledAnimationFlush(); } else { diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 05ad85dd7275b..9cc6f918aabbc 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -812,7 +812,7 @@ Document* ExternalResourceMap::RequestResource( return resource->mDocument; } - RefPtr& loadEntry = mPendingLoads.GetOrInsert(clone); + RefPtr& loadEntry = mPendingLoads.LookupOrInsert(clone); if (loadEntry) { RefPtr load(loadEntry); load.forget(aPendingLoad); diff --git a/dom/base/Document.h b/dom/base/Document.h index cb0bcd109e887..d02776e1ba49a 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -1635,7 +1635,7 @@ class Document : public nsINode, RawServoSelectorList* GetListOrInsertFrom(const nsACString& aSelector, F&& aFrom) { MOZ_ASSERT(NS_IsMainThread()); - return mTable.GetOrInsertWith(aSelector, std::forward(aFrom)).get(); + return mTable.LookupOrInsertWith(aSelector, std::forward(aFrom)).get(); } ~SelectorCache(); diff --git a/dom/base/DocumentOrShadowRoot.cpp b/dom/base/DocumentOrShadowRoot.cpp index e21fd01f3df6c..682971f6002dc 100644 --- a/dom/base/DocumentOrShadowRoot.cpp +++ b/dom/base/DocumentOrShadowRoot.cpp @@ -218,7 +218,7 @@ void DocumentOrShadowRoot::CloneAdoptedSheetsFrom( MOZ_ASSERT(clonedSheetMap); for (const StyleSheet* sheet : aSource.mAdoptedStyleSheets) { - RefPtr clone = clonedSheetMap->GetOrInsertWith( + RefPtr clone = clonedSheetMap->LookupOrInsertWith( sheet, [&] { return sheet->CloneAdoptedSheet(ownerDoc); }); MOZ_ASSERT(clone); MOZ_DIAGNOSTIC_ASSERT(clone->ConstructorDocumentMatches(ownerDoc)); @@ -753,7 +753,8 @@ nsRadioGroupStruct* DocumentOrShadowRoot::GetRadioGroup( nsRadioGroupStruct* DocumentOrShadowRoot::GetOrCreateRadioGroup( const nsAString& aName) { return mRadioGroups - .GetOrInsertWith(aName, [] { return MakeUnique(); }) + .LookupOrInsertWith(aName, + [] { return MakeUnique(); }) .get(); } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 3d15c0733d86d..e5e4ad09fa6df 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -3959,7 +3959,7 @@ void Element::RegisterIntersectionObserver(DOMIntersectionObserver* aObserver) { // notification task being scheduled. // -1: Non-intersecting. // >= 0: Intersecting, valid index of aObserver->mThresholds. - Unused << observers->GetOrInsert(aObserver, eUninitialized); + observers->LookupOrInsert(aObserver, eUninitialized); } void Element::UnregisterIntersectionObserver( diff --git a/dom/base/EventSourceEventService.cpp b/dom/base/EventSourceEventService.cpp index 9ce0a0d4360c1..c403dd06cddaf 100644 --- a/dom/base/EventSourceEventService.cpp +++ b/dom/base/EventSourceEventService.cpp @@ -203,8 +203,8 @@ EventSourceEventService::AddListener(uint64_t aInnerWindowID, WindowListener* listener = mWindows - .GetOrInsertWith(aInnerWindowID, - [] { return MakeUnique(); }) + .LookupOrInsertWith(aInnerWindowID, + [] { return MakeUnique(); }) .get(); listener->mListeners.AppendElement(aListener); diff --git a/dom/base/ResizeObserver.cpp b/dom/base/ResizeObserver.cpp index 7dd6a427dc46b..3ddaa5e3780a6 100644 --- a/dom/base/ResizeObserver.cpp +++ b/dom/base/ResizeObserver.cpp @@ -150,7 +150,7 @@ void ResizeObserver::Observe(Element& aTarget, mDocument->AddResizeObserver(*this); } - auto& observation = mObservationMap.GetOrInsert(&aTarget); + auto& observation = mObservationMap.LookupOrInsert(&aTarget); if (observation) { if (observation->BoxOptions() == aOptions.mBox) { // Already observed this target and the observed box is the same, so diff --git a/dom/base/nsDOMAttributeMap.cpp b/dom/base/nsDOMAttributeMap.cpp index faa8b39d7f6f2..12e607040eeda 100644 --- a/dom/base/nsDOMAttributeMap.cpp +++ b/dom/base/nsDOMAttributeMap.cpp @@ -118,7 +118,7 @@ Attr* nsDOMAttributeMap::GetAttribute(mozilla::dom::NodeInfo* aNodeInfo) { nsAttrKey attr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom()); - return mAttributeCache.GetOrInsertWith(attr, [&] { + return mAttributeCache.LookupOrInsertWith(attr, [&] { // Newly inserted entry! RefPtr ni = aNodeInfo; auto* nim = ni->NodeInfoManager(); diff --git a/dom/base/nsDOMMutationObserver.cpp b/dom/base/nsDOMMutationObserver.cpp index 2aa35b41e8e9d..d05f8923d4b2c 100644 --- a/dom/base/nsDOMMutationObserver.cpp +++ b/dom/base/nsDOMMutationObserver.cpp @@ -322,7 +322,7 @@ void nsMutationReceiver::ContentRemoved(nsIContent* aChild, auto* const transientReceivers = Observer() ->mTransientReceivers - .GetOrInsertWith( + .LookupOrInsertWith( aChild, [&isNewEntry] { isNewEntry = true; @@ -1040,7 +1040,7 @@ void nsAutoMutationBatch::Done() { if (allObservers.Length()) { auto* const transientReceivers = ob->mTransientReceivers - .GetOrInsertWith( + .LookupOrInsertWith( removed, [] { return MakeUnique>(); }) .get(); diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index e08cfdbb7f8fa..f91ca9b732f32 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -241,7 +241,7 @@ void nsFrameMessageManager::AddMessageListener(const nsAString& aMessageName, ErrorResult& aError) { auto* const listeners = mListeners - .GetOrInsertWith( + .LookupOrInsertWith( aMessageName, [] { return MakeUnique< @@ -316,7 +316,7 @@ void nsFrameMessageManager::AddWeakMessageListener( auto* const listeners = mListeners - .GetOrInsertWith( + .LookupOrInsertWith( aMessageName, [] { return MakeUnique< diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 2da36ad2b9c8a..22be3ce7107b2 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -7161,7 +7161,7 @@ ChromeMessageBroadcaster* nsGlobalWindowInner::GetGroupMessageManager( MOZ_ASSERT(IsChromeWindow()); return mChromeFields.mGroupMessageManagers - .GetOrInsertWith( + .LookupOrInsertWith( aGroup, [&] { return MakeAndAddRef(MessageManager()); diff --git a/dom/broadcastchannel/BroadcastChannelService.cpp b/dom/broadcastchannel/BroadcastChannelService.cpp index 8b475cc2952b1..685b5ffe1596d 100644 --- a/dom/broadcastchannel/BroadcastChannelService.cpp +++ b/dom/broadcastchannel/BroadcastChannelService.cpp @@ -83,7 +83,7 @@ void BroadcastChannelService::RegisterActor( auto* const parents = mAgents - .GetOrInsertWith( + .LookupOrInsertWith( aOriginChannelKey, [] { return MakeUnique>(); }) .get(); diff --git a/dom/clients/manager/ClientManagerService.cpp b/dom/clients/manager/ClientManagerService.cpp index ee98e601cc971..39b0aaddbbaa0 100644 --- a/dom/clients/manager/ClientManagerService.cpp +++ b/dom/clients/manager/ClientManagerService.cpp @@ -254,7 +254,7 @@ ClientSourceParent* ClientManagerService::FindSource( void ClientManagerService::WaitForSource(ClientHandleParent* aHandle, const nsID& aID) { - auto& entry = mPendingHandles.GetOrInsert(aID); + auto& entry = mPendingHandles.LookupOrInsert(aID); entry.AppendElement(aHandle); } diff --git a/dom/commandhandler/nsCommandManager.cpp b/dom/commandhandler/nsCommandManager.cpp index ecf1d391ada87..5beb0af76769c 100644 --- a/dom/commandhandler/nsCommandManager.cpp +++ b/dom/commandhandler/nsCommandManager.cpp @@ -82,8 +82,9 @@ nsCommandManager::AddCommandObserver(nsIObserver* aCommandObserver, // for each command in the table, we make a list of observers for that command auto* const commandObservers = mObserversTable - .GetOrInsertWith(aCommandToObserve, - [] { return mozilla::MakeUnique(); }) + .LookupOrInsertWith( + aCommandToObserve, + [] { return mozilla::MakeUnique(); }) .get(); // need to check that this command observer hasn't already been registered diff --git a/dom/events/EventListenerService.cpp b/dom/events/EventListenerService.cpp index f8c21e72d50b1..349148c5475f7 100644 --- a/dom/events/EventListenerService.cpp +++ b/dom/events/EventListenerService.cpp @@ -374,7 +374,7 @@ void EventListenerService::NotifyAboutMainThreadListenerChangeInternal( } RefPtr changes = - mPendingListenerChangesSet.GetOrInsertWith(aTarget, [&] { + mPendingListenerChangesSet.LookupOrInsertWith(aTarget, [&] { auto c = MakeRefPtr(aTarget); mPendingListenerChanges->AppendElement(c); return c; diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 5f9e2a2278d72..84970ef93afe9 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -4690,8 +4690,8 @@ OverOutElementsWrapper* EventStateManager::GetWrapperByEventID( return mMouseEnterLeaveHelper; } return mPointersEnterLeaveHelper - .GetOrInsertWith(pointer->pointerId, - [] { return new OverOutElementsWrapper(); }) + .LookupOrInsertWith(pointer->pointerId, + [] { return new OverOutElementsWrapper(); }) .get(); } diff --git a/dom/filehandle/ActorsParent.cpp b/dom/filehandle/ActorsParent.cpp index 302e0ec1c7d62..b16c9032498b7 100644 --- a/dom/filehandle/ActorsParent.cpp +++ b/dom/filehandle/ActorsParent.cpp @@ -674,7 +674,7 @@ void FileHandleThreadPool::Enqueue(FileHandle* aFileHandle, DirectoryInfo* directoryInfo = mDirectoryInfos - .GetOrInsertWith( + .LookupOrInsertWith( directoryId, [&] { return UniquePtr(new DirectoryInfo(this)); }) .get(); diff --git a/dom/html/HTMLAllCollection.cpp b/dom/html/HTMLAllCollection.cpp index 445c8cbc0a85b..e8862c8e4d278 100644 --- a/dom/html/HTMLAllCollection.cpp +++ b/dom/html/HTMLAllCollection.cpp @@ -105,12 +105,13 @@ static bool DocAllResultMatch(Element* aElement, int32_t aNamespaceID, nsContentList* HTMLAllCollection::GetDocumentAllList(const nsAString& aID) { return mNamedMap - .GetOrInsertWith(aID, - [this, &aID] { - RefPtr id = NS_Atomize(aID); - return new nsContentList(mDocument, DocAllResultMatch, - nullptr, nullptr, true, id); - }) + .LookupOrInsertWith(aID, + [this, &aID] { + RefPtr id = NS_Atomize(aID); + return new nsContentList(mDocument, + DocAllResultMatch, nullptr, + nullptr, true, id); + }) .get(); } diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 0f4644a1d1539..1ed911a7f0d87 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -2147,7 +2147,7 @@ HTMLFormElement::WalkRadioGroup(const nsAString& aName, void HTMLFormElement::AddToRadioGroup(const nsAString& aName, HTMLInputElement* aRadio) { if (aRadio->IsRequired()) { - uint32_t& value = mRequiredRadioButtonCounts.GetOrInsert(aName, 0); + uint32_t& value = mRequiredRadioButtonCounts.LookupOrInsert(aName, 0); ++value; } } diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index b03467171e5eb..b4e9ca5feb5a2 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -7628,11 +7628,11 @@ nsresult DatabaseConnection::UpdateRefcountFunction::ProcessValue( const auto entry = WrapNotNull(mFileInfoEntries - .GetOrInsertWith(id, - [&file] { - return MakeUnique( - file.FileInfoPtr()); - }) + .LookupOrInsertWith(id, + [&file] { + return MakeUnique( + file.FileInfoPtr()); + }) .get()); if (mInSavepoint) { @@ -16776,7 +16776,7 @@ void OpenDatabaseOp::EnsureDatabaseActor() { info->mLiveDatabases.AppendElement( WrapNotNullUnchecked(mDatabase.unsafeGetRawPtr())); } else { - // XXX Maybe use GetOrInsertWith above, to avoid a second lookup here? + // XXX Maybe use LookupOrInsertWith above, to avoid a second lookup here? info = gLiveDatabaseHashtable ->Put(mDatabaseId, MakeUnique( diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index ef4fa3de64ae3..fd4769965d08e 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -190,7 +190,7 @@ void WindowGlobalParent::OriginCounter::UpdateSiteOriginsFrom( aParent->DocumentPrincipal()->GetSiteOrigin(origin); if (aIncrease) { - int32_t& count = mOriginMap.GetOrInsert(origin); + int32_t& count = mOriginMap.LookupOrInsert(origin); count += 1; mMaxOrigins = std::max(mMaxOrigins, mOriginMap.Count()); } else if (auto entry = mOriginMap.Lookup(origin)) { diff --git a/dom/localstorage/ActorsParent.cpp b/dom/localstorage/ActorsParent.cpp index d37350938a677..cb6c7c10518b0 100644 --- a/dom/localstorage/ActorsParent.cpp +++ b/dom/localstorage/ActorsParent.cpp @@ -3228,7 +3228,7 @@ bool RecvPBackgroundLSObserverConstructor(PBackgroundLSObserverParent* aActor, nsTArray>* const array = gObservers - ->GetOrInsertWith( + ->LookupOrInsertWith( notNullObserver->Origin(), [] { return MakeUnique>>(); }) .get(); @@ -5451,7 +5451,7 @@ void Snapshot::SaveItem(const nsAString& aKey, const LSValue& aOldValue, } if (!mLoadedItems.GetEntry(aKey) && !mUnknownItems.GetEntry(aKey)) { - Unused << mValues.GetOrInsert(aKey, aOldValue); + mValues.LookupOrInsert(aKey, aOldValue); } if (aAffectsOrder && !mSavedKeys) { diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 3a11908a45617..dbe46ca990d2f 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -2793,7 +2793,7 @@ RefPtr MediaManager::GetUserMedia( // things down nsTArray* const array = self->mCallIds - .GetOrInsertWith( + .LookupOrInsertWith( windowID, [] { return MakeUnique>(); }) .get(); diff --git a/dom/media/MediaTrackGraph.cpp b/dom/media/MediaTrackGraph.cpp index 54c3954081d5e..d5702cde0a1cb 100644 --- a/dom/media/MediaTrackGraph.cpp +++ b/dom/media/MediaTrackGraph.cpp @@ -634,7 +634,7 @@ void MediaTrackGraphImpl::OpenAudioInputImpl(CubebUtils::AudioDeviceID aID, // Only allow one device per MTG (hence, per document), but allow opening a // device multiple times nsTArray>& listeners = - mInputDeviceUsers.GetOrInsert(aID); + mInputDeviceUsers.LookupOrInsert(aID); if (listeners.IsEmpty() && mInputDeviceUsers.Count() > 1) { // We don't support opening multiple input device in a graph for now. listeners.RemoveElement(aID); diff --git a/dom/media/gmp/GMPMemoryStorage.cpp b/dom/media/gmp/GMPMemoryStorage.cpp index e535c6cf769f6..711579255a267 100644 --- a/dom/media/gmp/GMPMemoryStorage.cpp +++ b/dom/media/gmp/GMPMemoryStorage.cpp @@ -13,10 +13,10 @@ class GMPMemoryStorage : public GMPStorage { GMPErr Open(const nsCString& aRecordName) override { MOZ_ASSERT(!IsOpen(aRecordName)); - Record* record = - mRecords - .GetOrInsertWith(aRecordName, [] { return MakeUnique(); }) - .get(); + Record* record = mRecords + .LookupOrInsertWith( + aRecordName, [] { return MakeUnique(); }) + .get(); record->mIsOpen = true; return GMPNoErr; } diff --git a/dom/media/ogg/OggCodecState.cpp b/dom/media/ogg/OggCodecState.cpp index 5ddc19f243fa2..e8c80775d03d6 100644 --- a/dom/media/ogg/OggCodecState.cpp +++ b/dom/media/ogg/OggCodecState.cpp @@ -1712,7 +1712,7 @@ bool SkeletonState::DecodeFisbone(ogg_packet* aPacket) { if ((i == 0 && IsAscii(strMsg)) || (i != 0 && IsUtf8(strMsg))) { EMsgHeaderType eHeaderType = kFieldTypeMaps[i].mMsgHeaderType; - Unused << field->mValuesStore.GetOrInsertWith( + Unused << field->mValuesStore.LookupOrInsertWith( eHeaderType, [i, msgHead, msgProbe]() { uint32_t nameLen = strlen(kFieldTypeMaps[i].mPatternToRecognize); diff --git a/dom/payments/PaymentRequestManager.cpp b/dom/payments/PaymentRequestManager.cpp index 20c9b1e9736f6..5932ddaf4c286 100644 --- a/dom/payments/PaymentRequestManager.cpp +++ b/dom/payments/PaymentRequestManager.cpp @@ -380,7 +380,7 @@ nsresult PaymentRequestManager::SendRequestPayment( } if (aResponseExpected) { - ++mActivePayments.GetOrInsert(aRequest, 0); + ++mActivePayments.LookupOrInsert(aRequest, 0); } return NS_OK; } diff --git a/dom/presentation/PresentationServiceBase.h b/dom/presentation/PresentationServiceBase.h index eda02c52dd935..06529ebcab0c1 100644 --- a/dom/presentation/PresentationServiceBase.h +++ b/dom/presentation/PresentationServiceBase.h @@ -80,8 +80,8 @@ class PresentationServiceBase { } mRespondingSessionIds - .GetOrInsertWith(aWindowId, - [] { return MakeUnique>(); }) + .LookupOrInsertWith(aWindowId, + [] { return MakeUnique>(); }) ->AppendElement(nsString(aSessionId)); mRespondingWindowIds.Put(aSessionId, aWindowId); } @@ -150,11 +150,11 @@ class PresentationServiceBase { for (const auto& url : aAvailabilityUrls) { AvailabilityEntry* const entry = mAvailabilityUrlTable - .GetOrInsertWith(url, - [&] { - aAddedUrls.AppendElement(url); - return MakeUnique(); - }) + .LookupOrInsertWith(url, + [&] { + aAddedUrls.AppendElement(url); + return MakeUnique(); + }) .get(); if (!entry->mListeners.Contains(aListener)) { entry->mListeners.AppendElement(aListener); @@ -228,7 +228,7 @@ class PresentationServiceBase { nsIPresentationAvailabilityListener* listener = entry->mListeners.ObjectAt(i); availabilityListenerTable - .GetOrInsertWith( + .LookupOrInsertWith( listener, [] { return MakeUnique>(); }) ->AppendElement(it.Key()); } diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 4a3f6ca1fc4fb..b39be296a036c 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -3303,7 +3303,7 @@ void QuotaManager::RegisterDirectoryLock(DirectoryLockImpl& aLock) { // just use that like an inefficient use counter. Can't we just change // DirectoryLockTable to a nsDataHashtable? directoryLockTable - .GetOrInsertWith( + .LookupOrInsertWith( aLock.Origin(), [this, &aLock] { if (!IsShuttingDown()) { @@ -4368,7 +4368,7 @@ already_AddRefed QuotaManager::GetQuotaObject( // pointer directly since QuotaObject::AddRef would try to acquire the same // mutex. const NotNull quotaObject = - originInfo->mQuotaObjects.GetOrInsertWith(path, [&] { + originInfo->mQuotaObjects.LookupOrInsertWith(path, [&] { // Create a new QuotaObject. The hashtable is not responsible to // delete the QuotaObject. return WrapNotNullUnchecked( @@ -6048,7 +6048,7 @@ QuotaManager::EnsurePersistentOriginIsInitialized( }(); if (auto& info = - mOriginInitializationInfos.GetOrInsert(aOriginMetadata.mOrigin); + mOriginInitializationInfos.LookupOrInsert(aOriginMetadata.mOrigin); !info.mPersistentOriginAttempted) { Telemetry::Accumulate(Telemetry::QM_FIRST_INITIALIZATION_ATTEMPT, kPersistentOriginTelemetryKey, @@ -6099,7 +6099,8 @@ QuotaManager::EnsureTemporaryOriginIsInitialized( return std::pair(std::move(directory), created); }(); - auto& info = mOriginInitializationInfos.GetOrInsert(aOriginMetadata.mOrigin); + auto& info = + mOriginInitializationInfos.LookupOrInsert(aOriginMetadata.mOrigin); if (!info.mTemporaryOriginAttempted) { Telemetry::Accumulate(Telemetry::QM_FIRST_INITIALIZATION_ATTEMPT, kTemporaryOriginTelemetryKey, @@ -6674,7 +6675,8 @@ already_AddRefed QuotaManager::LockedGetOrCreateGroupInfo( GroupInfoPair* const pair = mGroupInfoPairs - .GetOrInsertWith(aGroup, [] { return MakeUnique(); }) + .LookupOrInsertWith(aGroup, + [] { return MakeUnique(); }) .get(); RefPtr groupInfo = pair->LockedGetGroupInfo(aPersistenceType); @@ -6939,15 +6941,16 @@ bool QuotaManager::IsSanitizedOriginValid(const nsACString& aSanitizedOrigin) { AssertIsOnIOThread(); // Do not parse this sanitized origin string, if we already parsed it. - return mValidOrigins.GetOrInsertWith(aSanitizedOrigin, [&aSanitizedOrigin] { - nsCString spec; - OriginAttributes attrs; - nsCString originalSuffix; - const auto result = OriginParser::ParseOrigin(aSanitizedOrigin, spec, - &attrs, originalSuffix); - - return result == OriginParser::ValidOrigin; - }); + return mValidOrigins.LookupOrInsertWith( + aSanitizedOrigin, [&aSanitizedOrigin] { + nsCString spec; + OriginAttributes attrs; + nsCString originalSuffix; + const auto result = OriginParser::ParseOrigin(aSanitizedOrigin, spec, + &attrs, originalSuffix); + + return result == OriginParser::ValidOrigin; + }); } int64_t QuotaManager::GenerateDirectoryLockId() { diff --git a/dom/serviceworkers/ServiceWorkerManager.cpp b/dom/serviceworkers/ServiceWorkerManager.cpp index 1acf7ff2ca8cb..790f9c0d37f52 100644 --- a/dom/serviceworkers/ServiceWorkerManager.cpp +++ b/dom/serviceworkers/ServiceWorkerManager.cpp @@ -1594,7 +1594,7 @@ ServiceWorkerManager::GetOrCreateJobQueue(const nsACString& aKey, .get(); } - RefPtr queue = data->mJobQueues.GetOrInsertWith( + RefPtr queue = data->mJobQueues.LookupOrInsertWith( aScope, [] { return new ServiceWorkerJobQueue(); }); return queue.forget(); } @@ -1908,7 +1908,7 @@ void ServiceWorkerManager::AddScopeAndRegistration( auto* const data = swm->mRegistrationInfos - .GetOrInsertWith( + .LookupOrInsertWith( scopeKey, [] { return MakeUnique(); }) .get(); diff --git a/dom/storage/SessionStorageManager.cpp b/dom/storage/SessionStorageManager.cpp index 8c19152d665cf..5ecc88b846b6f 100644 --- a/dom/storage/SessionStorageManager.cpp +++ b/dom/storage/SessionStorageManager.cpp @@ -633,8 +633,8 @@ BackgroundSessionStorageManager* BackgroundSessionStorageManager::GetOrCreate( } return sManagers - ->GetOrInsertWith(aTopContextId, - [] { return new BackgroundSessionStorageManager(); }) + ->LookupOrInsertWith(aTopContextId, + [] { return new BackgroundSessionStorageManager(); }) .get(); } diff --git a/dom/storage/StorageIPC.cpp b/dom/storage/StorageIPC.cpp index 78d18f9fe5e2d..1f5f3c91ecc4c 100644 --- a/dom/storage/StorageIPC.cpp +++ b/dom/storage/StorageIPC.cpp @@ -1464,7 +1464,7 @@ mozilla::ipc::IPCResult RecvPBackgroundLocalStorageCacheConstructor( } gLocalStorageCacheParents - ->GetOrInsertWith( + ->LookupOrInsertWith( aOriginKey, [] { return MakeUnique>(); }) ->AppendElement(actor); diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 0bfdf3cc978b1..bb12d3653cbbb 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -1151,7 +1151,7 @@ bool RuntimeService::RegisterWorker(WorkerPrivate& aWorkerPrivate) { auto* const domainInfo = mDomainMap - .GetOrInsertWith( + .LookupOrInsertWith( domain, [&domain, parent] { NS_ASSERTION(!parent, "Shouldn't have a parent here!"); @@ -1224,7 +1224,7 @@ bool RuntimeService::RegisterWorker(WorkerPrivate& aWorkerPrivate) { // that of dom windows. if (auto* const windowArray = mWindowMap - .GetOrInsertWith( + .LookupOrInsertWith( window, [] { return MakeUnique>(1); }) .get(); diff --git a/dom/xul/nsXULPrototypeCache.cpp b/dom/xul/nsXULPrototypeCache.cpp index 40379bda51ebd..6c5539a224650 100644 --- a/dom/xul/nsXULPrototypeCache.cpp +++ b/dom/xul/nsXULPrototypeCache.cpp @@ -194,7 +194,7 @@ nsresult nsXULPrototypeCache::PutScript(nsIURI* aURI, } #endif - mScriptTable.GetOrInsert(aURI).set(aScriptObject); + mScriptTable.LookupOrInsert(aURI).set(aScriptObject); return NS_OK; } diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 64cb450f77a91..52bd92742b969 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -868,8 +868,8 @@ EGLSurface GLContextEGL::CreateWaylandBufferSurface( if (surface) { #ifdef MOZ_GTK_WAYLAND MOZ_ASSERT(!sWaylandGLSurface.Contains(surface)); - sWaylandGLSurface.GetOrInsert(surface, - new WaylandGLSurface(wlsurface, eglwindow)); + sWaylandGLSurface.LookupOrInsert( + surface, new WaylandGLSurface(wlsurface, eglwindow)); #endif } diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 64b32607669cb..cdc50a3fe82b7 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -2136,7 +2136,7 @@ bool LayerManager::AddPendingScrollUpdateForNextTransaction( return false; } - mPendingScrollUpdates.GetOrInsert(aScrollId).AppendElement(aUpdateInfo); + mPendingScrollUpdates.LookupOrInsert(aScrollId).AppendElement(aUpdateInfo); return true; } diff --git a/gfx/layers/wr/WebRenderCommandBuilder.h b/gfx/layers/wr/WebRenderCommandBuilder.h index 71efcaa3f833c..90ef6df79544f 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.h +++ b/gfx/layers/wr/WebRenderCommandBuilder.h @@ -136,7 +136,7 @@ class WebRenderCommandBuilder final { frame->AddProperty(WebRenderUserDataProperty::Key(), userDataTable); } - RefPtr& data = userDataTable->GetOrInsertWith( + RefPtr& data = userDataTable->LookupOrInsertWith( WebRenderUserDataKey(aItem->GetPerFrameKey(), T::Type()), [&] { auto data = MakeRefPtr(GetRenderRootStateManager(), aItem); mWebRenderUserDatas.PutEntry(data); diff --git a/gfx/thebes/gfxFT2FontBase.cpp b/gfx/thebes/gfxFT2FontBase.cpp index ad5fc09bbc6f2..55f8b89896df7 100644 --- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -644,7 +644,7 @@ const gfxFT2FontBase::GlyphMetrics& gfxFT2FontBase::GetCachedGlyphMetrics( return *metrics; } - GlyphMetrics& metrics = mGlyphMetrics->GetOrInsert(aGID); + GlyphMetrics& metrics = mGlyphMetrics->LookupOrInsert(aGID); IntRect bounds; if (GetFTGlyphExtents(aGID, &metrics.mAdvance, &bounds)) { metrics.SetBounds(bounds); diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index e78a0a8038ea8..95e87fa891930 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -1593,7 +1593,7 @@ void gfxFcPlatformFontList::InitSharedFontListForPlatform() { // Add new family record if one doesn't already exist. faceListPtr = faces - .GetOrInsertWith( + .LookupOrInsertWith( keyName, [&] { FontVisibility visibility = @@ -1656,18 +1656,19 @@ void gfxFcPlatformFontList::InitSharedFontListForPlatform() { ToLowerCase(keyName); faces - .GetOrInsertWith(keyName, - [&] { - FontVisibility visibility = - aAppFont ? FontVisibility::Base - : GetVisibilityForFamily(keyName); - families.AppendElement(fontlist::Family::InitData( - keyName, otherFamilyName, - fontlist::Family::kNoIndex, visibility, - /*bundled*/ aAppFont, /*badUnderline*/ false)); - - return MakeUnique(); - }) + .LookupOrInsertWith( + keyName, + [&] { + FontVisibility visibility = + aAppFont ? FontVisibility::Base + : GetVisibilityForFamily(keyName); + families.AppendElement(fontlist::Family::InitData( + keyName, otherFamilyName, fontlist::Family::kNoIndex, + visibility, + /*bundled*/ aAppFont, /*badUnderline*/ false)); + + return MakeUnique(); + }) ->AppendElement(fontlist::Face::InitData{descriptor, 0, false, weight, stretch, style}); diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index bc2ed9342f600..bac47615b4cae 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -1589,7 +1589,8 @@ gfxFontEntry* gfxPlatformFontList::FindFontForFamily( gfxFontEntry* gfxPlatformFontList::GetOrCreateFontEntry( fontlist::Face* aFace, const fontlist::Family* aFamily) { return mFontEntries - .GetOrInsertWith(aFace, [=] { return CreateFontEntry(aFace, aFamily); }) + .LookupOrInsertWith(aFace, + [=] { return CreateFontEntry(aFace, aFamily); }) .get(); } diff --git a/intl/locale/DateTimeFormat.cpp b/intl/locale/DateTimeFormat.cpp index be8cad047961a..eaaa354b49706 100644 --- a/intl/locale/DateTimeFormat.cpp +++ b/intl/locale/DateTimeFormat.cpp @@ -251,7 +251,7 @@ nsresult DateTimeFormat::FormatUDateTime( new nsDataHashtable(kMaxCachedFormats); } - UDateFormat*& dateTimeFormat = mFormatCache->GetOrInsert(key); + UDateFormat*& dateTimeFormat = mFormatCache->LookupOrInsert(key); if (!dateTimeFormat) { // We didn't have a cached formatter for this key, so create one. diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 7f90742b445cd..70e780753d372 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -532,13 +532,13 @@ class ChannelCountReporter final : public nsIMemoryReporter { if (!sChannelCounts) { sChannelCounts = new CountTable; } - sChannelCounts->GetOrInsert(aName).Inc(); + sChannelCounts->LookupOrInsert(aName).Inc(); } static void Decrement(const char* aName) { StaticMutexAutoLock countLock(sChannelCountMutex); MOZ_ASSERT(sChannelCounts); - sChannelCounts->GetOrInsert(aName).Dec(); + sChannelCounts->LookupOrInsert(aName).Dec(); } }; diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 49bc2c9ce74e1..25764aab80d7e 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -10553,8 +10553,8 @@ void ReflowCountMgr::Add(const char* aName, nsIFrame* aFrame) { if (mDumpFrameCounts) { auto* const counter = mCounts - .GetOrInsertWith(aName, - [this] { return MakeUnique(this); }) + .LookupOrInsertWith( + aName, [this] { return MakeUnique(this); }) .get(); counter->Add(); } @@ -10565,14 +10565,14 @@ void ReflowCountMgr::Add(const char* aName, nsIFrame* aFrame) { SprintfLiteral(key, "%p", (void*)aFrame); auto* const counter = mIndiFrameCounts - .GetOrInsertWith(key, - [&aName, &aFrame, this]() { - auto counter = - MakeUnique(this); - counter->mFrame = aFrame; - counter->mName.AssignASCII(aName); - return counter; - }) + .LookupOrInsertWith(key, + [&aName, &aFrame, this]() { + auto counter = + MakeUnique(this); + counter->mFrame = aFrame; + counter->mName.AssignASCII(aName); + return counter; + }) .get(); // this eliminates extra counts from super classes if (counter && counter->mName.EqualsASCII(aName)) { diff --git a/layout/base/nsCounterManager.cpp b/layout/base/nsCounterManager.cpp index 295c9ff9b384c..2dcff3b245fb7 100644 --- a/layout/base/nsCounterManager.cpp +++ b/layout/base/nsCounterManager.cpp @@ -309,7 +309,8 @@ bool nsCounterManager::AddCounterChanges(nsIFrame* aFrame) { nsCounterList* nsCounterManager::CounterListFor(nsAtom* aCounterName) { MOZ_ASSERT(aCounterName); return mNames - .GetOrInsertWith(aCounterName, [] { return MakeUnique(); }) + .LookupOrInsertWith(aCounterName, + [] { return MakeUnique(); }) .get(); } diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index bedd17008d1b7..44395efcd721c 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -1356,7 +1356,8 @@ bool nsRefreshDriver::AddImageRequest(imgIRequest* aRequest) { } else { auto* const start = mStartTable - .GetOrInsertWith(delay, [] { return MakeUnique(); }) + .LookupOrInsertWith(delay, + [] { return MakeUnique(); }) .get(); start->mEntries.PutEntry(aRequest); } diff --git a/layout/painting/RetainedDisplayListBuilder.h b/layout/painting/RetainedDisplayListBuilder.h index 0c4cd735989db..38e1b0f7f2d5f 100644 --- a/layout/painting/RetainedDisplayListBuilder.h +++ b/layout/painting/RetainedDisplayListBuilder.h @@ -48,7 +48,7 @@ struct RetainedDisplayListData { * frame does not exist in this RetainedDisplayListData, it is added with * default constructible flags FrameFlags::None. */ - FrameFlags& Flags(nsIFrame* aFrame) { return mFrames.GetOrInsert(aFrame); } + FrameFlags& Flags(nsIFrame* aFrame) { return mFrames.LookupOrInsert(aFrame); } /** * Returns flags set for the given |aFrame|, or FrameFlags::None if the frame diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 6773a7c1b5256..1e97a6f908d63 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -1935,7 +1935,7 @@ bool nsDisplayListBuilder::AddToWillChangeBudget(nsIFrame* aFrame, const uint32_t cost = GetLayerizationCost(aSize); DocumentWillChangeBudget& documentBudget = - mDocumentWillChangeBudgets.GetOrInsert(presContext); + mDocumentWillChangeBudgets.LookupOrInsert(presContext); const bool onBudget = (documentBudget + cost) / gWillChangeAreaMultiplier < budgetLimit; diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 6ef7fcf27a929..95aaf4c8600d0 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -2029,7 +2029,7 @@ void SelectionRangeState::SelectNodesExceptInSubtree(const Position& aStart, static constexpr auto kEllipsis = u"\x2026"_ns; nsINode* root = aStart.mNode->SubtreeRoot(); - auto& start = mPositions.GetOrInsertWith(root, [&] { + auto& start = mPositions.LookupOrInsertWith(root, [&] { return Position{root, 0}; }); diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 64cf3ac4d4e72..033a754227855 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -1279,7 +1279,7 @@ void FontFaceSet::CacheFontLoadability() { if (src.mSourceType != gfxFontFaceSrc::eSourceType_URL) { continue; } - Unused << mAllowedFontLoads.GetOrInsertWith( + mAllowedFontLoads.LookupOrInsertWith( &src, [&] { return IsFontLoadAllowed(src); }); } } diff --git a/layout/style/ImageLoader.cpp b/layout/style/ImageLoader.cpp index 1f8ce88d12791..7793cc9728153 100644 --- a/layout/style/ImageLoader.cpp +++ b/layout/style/ImageLoader.cpp @@ -170,7 +170,7 @@ void ImageLoader::AssociateRequestToFrame(imgIRequest* aRequest, auto* const frameSet = mRequestToFrameMap - .GetOrInsertWith( + .LookupOrInsertWith( aRequest, [&] { mDocument->ImageTracker()->Add(aRequest); @@ -194,11 +194,11 @@ void ImageLoader::AssociateRequestToFrame(imgIRequest* aRequest, auto* const requestSet = mFrameToRequestMap - .GetOrInsertWith(aFrame, - [=]() { - aFrame->SetHasImageRequest(true); - return MakeUnique(); - }) + .LookupOrInsertWith(aFrame, + [=]() { + aFrame->SetHasImageRequest(true); + return MakeUnique(); + }) .get(); // Add frame to the frameSet, and handle any special processing the @@ -440,8 +440,8 @@ already_AddRefed ImageLoader::LoadImage( if (NS_FAILED(rv) || !request) { return nullptr; } - sImages->GetOrInsertWith(request, - [] { return MakeUnique(); }); + sImages->LookupOrInsertWith(request, + [] { return MakeUnique(); }); return request.forget(); } diff --git a/layout/style/ShadowParts.cpp b/layout/style/ShadowParts.cpp index c80ed254dfe38..b51b8016d0a6e 100644 --- a/layout/style/ShadowParts.cpp +++ b/layout/style/ShadowParts.cpp @@ -107,7 +107,8 @@ ShadowParts ShadowParts::Parse(const nsAString& aString) { } nsAtom* second = mapping.second.get(); parts.mMappings - .GetOrInsertWith(mapping.first, [] { return MakeUnique(); }) + .LookupOrInsertWith(mapping.first, + [] { return MakeUnique(); }) ->AppendElement(std::move(mapping.second)); parts.mReverseMappings.Put(second, std::move(mapping.first)); } diff --git a/layout/style/SharedStyleSheetCache.cpp b/layout/style/SharedStyleSheetCache.cpp index bdbfd4771b4f4..0ac68139ec829 100644 --- a/layout/style/SharedStyleSheetCache.cpp +++ b/layout/style/SharedStyleSheetCache.cpp @@ -573,8 +573,8 @@ void SharedStyleSheetCache::CancelLoadsForLoader(css::Loader& aLoader) { void SharedStyleSheetCache::RegisterLoader(css::Loader& aLoader) { MOZ_ASSERT(aLoader.GetDocument()); - mLoaderPrincipalRefCnt.GetOrInsert(aLoader.GetDocument()->NodePrincipal(), - 0) += 1; + mLoaderPrincipalRefCnt.LookupOrInsert(aLoader.GetDocument()->NodePrincipal(), + 0) += 1; } void SharedStyleSheetCache::UnregisterLoader(css::Loader& aLoader) { diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index b26bf11313fbd..48bb4040270e2 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -1232,7 +1232,7 @@ static void AddAccessCount(const nsACString& aPrefName) { // 1474789), and triggers assertions here if we try to add usage count entries // from background threads. if (NS_IsMainThread()) { - uint32_t& count = gAccessCounts->GetOrInsert(aPrefName); + uint32_t& count = gAccessCounts->LookupOrInsert(aPrefName); count++; } } diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index 792696007f78a..819f9a645b543 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -2196,7 +2196,7 @@ void CacheFile::QueueChunkListener(uint32_t aIndex, item->mCallback = aCallback; mChunkListeners - .GetOrInsertWith(aIndex, [] { return MakeUnique(); }) + .LookupOrInsertWith(aIndex, [] { return MakeUnique(); }) ->mItems.AppendElement(item); } diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index df04262508136..b3715b6aa4f43 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -1565,7 +1565,7 @@ nsresult CacheStorageService::AddStorageEntry( // Ensure storage table CacheEntryTable* const entries = sGlobalEntryTables - ->GetOrInsertWith( + ->LookupOrInsertWith( aContextKey, [&aContextKey] { LOG((" new storage entries table for context '%s'", diff --git a/netwerk/dns/ChildDNSService.cpp b/netwerk/dns/ChildDNSService.cpp index 3f3cf051a5f76..9cc10f6783677 100644 --- a/netwerk/dns/ChildDNSService.cpp +++ b/netwerk/dns/ChildDNSService.cpp @@ -136,7 +136,7 @@ nsresult ChildDNSService::AsyncResolveInternal( GetDNSRecordHashKey(hostname, DNSResolverInfo::URL(aResolver), type, aOriginAttributes, flags, originalListenerAddr, key); mPendingRequests - .GetOrInsertWith( + .LookupOrInsertWith( key, [] { return MakeUnique>>(); }) ->AppendElement(sender); diff --git a/netwerk/dns/DNSPacket.cpp b/netwerk/dns/DNSPacket.cpp index 282f8e70cdb45..d170f8b72987f 100644 --- a/netwerk/dns/DNSPacket.cpp +++ b/netwerk/dns/DNSPacket.cpp @@ -860,7 +860,7 @@ nsresult DNSPacket::DecodeInternal( auto parseRecord = [&]() { LOG(("Parsing additional record type: %u", type)); - auto& entry = aAdditionalRecords.GetOrInsertWith( + auto& entry = aAdditionalRecords.LookupOrInsertWith( qname, [] { return MakeUnique(); }); switch (type) { diff --git a/netwerk/dns/GetAddrInfo.cpp b/netwerk/dns/GetAddrInfo.cpp index 7200c7330d1bd..ba22a283bdd6e 100644 --- a/netwerk/dns/GetAddrInfo.cpp +++ b/netwerk/dns/GetAddrInfo.cpp @@ -423,7 +423,7 @@ NS_IMETHODIMP NativeDNSResolverOverride::AddIPOverride( } AutoWriteLock lock(mLock); - auto& overrides = mOverrides.GetOrInsert(aHost); + auto& overrides = mOverrides.LookupOrInsert(aHost); overrides.AppendElement(tempAddr); return NS_OK; diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index a07b23c8ca5cb..dd8166c2a7cf6 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -1435,8 +1435,8 @@ nsDNSService::ReportFailedSVCDomainName(const nsACString& aOwnerName, MutexAutoLock lock(mLock); mFailedSVCDomainNames - .GetOrInsertWith(aOwnerName, - [] { return MakeUnique>(1); }) + .LookupOrInsertWith(aOwnerName, + [] { return MakeUnique>(1); }) ->AppendElement(aSVCDomainName); return NS_OK; } diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index d4d512c199b32..c1480f80cfda5 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -906,7 +906,7 @@ nsresult nsHostResolver::GetHostRecord(const nsACString& host, nsHostKey key(host, aTrrServer, type, flags, af, pb, originSuffix); RefPtr rec = - mRecordDB.GetOrInsertWith(key, [&] { return InitRecord(key); }); + mRecordDB.LookupOrInsertWith(key, [&] { return InitRecord(key); }); if (rec->IsAddrRecord()) { RefPtr addrRec = do_QueryObject(rec); if (addrRec->addr) { @@ -1049,7 +1049,7 @@ nsresult nsHostResolver::ResolveHost(const nsACString& aHost, } RefPtr rec = - mRecordDB.GetOrInsertWith(key, [&] { return InitRecord(key); }); + mRecordDB.LookupOrInsertWith(key, [&] { return InitRecord(key); }); RefPtr addrRec = do_QueryObject(rec); MOZ_ASSERT(rec, "Record should not be null"); diff --git a/netwerk/protocol/http/PendingTransactionQueue.cpp b/netwerk/protocol/http/PendingTransactionQueue.cpp index 9c3de78cc74db..00de7f135b96b 100644 --- a/netwerk/protocol/http/PendingTransactionQueue.cpp +++ b/netwerk/protocol/http/PendingTransactionQueue.cpp @@ -58,7 +58,7 @@ void PendingTransactionQueue::InsertTransactionNormal( uint64_t windowId = TabIdForQueuing(info->Transaction()); nsTArray>* const infoArray = mPendingTransactionTable - .GetOrInsertWith( + .LookupOrInsertWith( windowId, [] { return MakeUnique>>(); diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 3ee2203cf608a..771de43332b1d 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -805,7 +805,7 @@ void nsHttpConnectionMgr::UpdateCoalescingForNewConn( ent->mCoalescingKeys[i].get())); mCoalescingHash - .GetOrInsertWith( + .LookupOrInsertWith( ent->mCoalescingKeys[i], [] { LOG(("UpdateCoalescingForNewConn() need new list element\n")); @@ -3345,8 +3345,8 @@ void nsHttpConnectionMgr::RegisterOriginCoalescingKey(HttpConnectionBase* conn, nsCString newKey; BuildOriginFrameHashKey(newKey, ci, host, port); mCoalescingHash - .GetOrInsertWith(newKey, - [] { return MakeUnique>(1); }) + .LookupOrInsertWith(newKey, + [] { return MakeUnique>(1); }) ->AppendElement( do_GetWeakReference(static_cast(conn))); diff --git a/netwerk/protocol/websocket/WebSocketEventService.cpp b/netwerk/protocol/websocket/WebSocketEventService.cpp index afa4bea68ad29..253966f906ae5 100644 --- a/netwerk/protocol/websocket/WebSocketEventService.cpp +++ b/netwerk/protocol/websocket/WebSocketEventService.cpp @@ -370,7 +370,7 @@ WebSocketEventService::AddListener(uint64_t aInnerWindowID, ++mCountListeners; mWindows - .GetOrInsertWith( + .LookupOrInsertWith( aInnerWindowID, [&] { auto listener = MakeUnique(); diff --git a/netwerk/streamconv/nsStreamConverterService.cpp b/netwerk/streamconv/nsStreamConverterService.cpp index cf99bd6dfecf7..43fd758ad361d 100644 --- a/netwerk/streamconv/nsStreamConverterService.cpp +++ b/netwerk/streamconv/nsStreamConverterService.cpp @@ -120,12 +120,12 @@ nsresult nsStreamConverterService::AddAdjacency(const char* aContractID) { nsTArray>* const fromEdges = mAdjacencyList - .GetOrInsertWith( + .LookupOrInsertWith( fromStr, [] { return mozilla::MakeUnique>>(); }) .get(); - mozilla::Unused << mAdjacencyList.GetOrInsertWith( + mozilla::Unused << mAdjacencyList.LookupOrInsertWith( toStr, [] { return mozilla::MakeUnique>>(); }); // Now we know the FROM and TO types are represented as keys in the hashtable. diff --git a/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp b/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp index 7011ac41434a6..d8d55a0d7226a 100644 --- a/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp +++ b/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp @@ -35,7 +35,7 @@ void TemporaryAccessGrantObserver::Create(PermissionManager* aPM, if (!sObservers) { sObservers = MakeUnique(); } - Unused << sObservers->GetOrInsertWith( + sObservers->LookupOrInsertWith( std::make_pair(nsCOMPtr(aPrincipal), nsCString(aType)), [&]() -> nsCOMPtr { // Only create a new observer if we don't have a matching diff --git a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp index 69e729edf59cb..59756e2296604 100644 --- a/toolkit/components/filewatcher/NativeFileWatcherWin.cpp +++ b/toolkit/components/filewatcher/NativeFileWatcherWin.cpp @@ -1098,8 +1098,8 @@ void NativeFileWatcherIOTask::AppendCallbacksToHashtables( aOnErrorHandle) { ChangeCallbackArray* const callbacksArray = mChangeCallbacksTable - .GetOrInsertWith(aPath, - [] { return MakeUnique(); }) + .LookupOrInsertWith(aPath, + [] { return MakeUnique(); }) .get(); // Now we do have an entry for that path. Check to see if the callback is @@ -1115,8 +1115,8 @@ void NativeFileWatcherIOTask::AppendCallbacksToHashtables( // Same thing for the error callback. ErrorCallbackArray* const errorCallbacksArray = mErrorCallbacksTable - .GetOrInsertWith(aPath, - [] { return MakeUnique(); }) + .LookupOrInsertWith(aPath, + [] { return MakeUnique(); }) .get(); ErrorCallbackArray::index_type errorCallbackIndex = diff --git a/toolkit/components/telemetry/core/Stopwatch.cpp b/toolkit/components/telemetry/core/Stopwatch.cpp index ff858ca4df9e8..e8737a938fe7d 100644 --- a/toolkit/components/telemetry/core/Stopwatch.cpp +++ b/toolkit/components/telemetry/core/Stopwatch.cpp @@ -137,7 +137,7 @@ NS_IMPL_ISUPPORTS(TimerKeys, TimerKeys) Timer* TimerKeys::Get(const nsAString& aKey, bool aCreate) { if (aCreate) { - return mTimers.GetOrInsertWith(aKey, [] { return new Timer(); }); + return mTimers.LookupOrInsertWith(aKey, [] { return new Timer(); }); } return mTimers.GetWeak(aKey); } diff --git a/toolkit/components/telemetry/core/TelemetryEvent.cpp b/toolkit/components/telemetry/core/TelemetryEvent.cpp index 476f29c27465c..84fec64175dc5 100644 --- a/toolkit/components/telemetry/core/TelemetryEvent.cpp +++ b/toolkit/components/telemetry/core/TelemetryEvent.cpp @@ -376,8 +376,8 @@ bool IsExpired(const EventKey& key) { return key.id == kExpiredEventId; } EventRecordArray* GetEventRecordsForProcess(const StaticMutexAutoLock& lock, ProcessID processType) { return gEventRecords - .GetOrInsertWith(uint32_t(processType), - [] { return MakeUnique(); }) + .LookupOrInsertWith(uint32_t(processType), + [] { return MakeUnique(); }) .get(); } diff --git a/toolkit/components/telemetry/core/TelemetryOrigin.cpp b/toolkit/components/telemetry/core/TelemetryOrigin.cpp index 6c32796d987b7..6b601525fcee3 100644 --- a/toolkit/components/telemetry/core/TelemetryOrigin.cpp +++ b/toolkit/components/telemetry/core/TelemetryOrigin.cpp @@ -373,14 +373,14 @@ nsresult TelemetryOrigin::RecordOrigin(OriginMetricID aId, // Only record one unknown origin per metric per snapshot. // (otherwise we may get swamped and blow our data budget.) if (gMetricToOriginBag->Contains(aId) && - gMetricToOriginBag->GetOrInsert(aId).Contains(kUnknownOrigin)) { + gMetricToOriginBag->LookupOrInsert(aId).Contains(kUnknownOrigin)) { return NS_OK; } origin = kUnknownOrigin; } - auto& originBag = gMetricToOriginBag->GetOrInsert(aId); - originBag.GetOrInsert(origin)++; + auto& originBag = gMetricToOriginBag->LookupOrInsert(aId); + originBag.LookupOrInsert(origin)++; prioDataCount = PrioDataCount(locker); } @@ -425,7 +425,7 @@ nsresult TelemetryOrigin::GetOriginSnapshot(bool aClear, JSContext* aCx, } else { auto iter = gMetricToOriginBag->ConstIter(); for (; !iter.Done(); iter.Next()) { - OriginBag& bag = copy.GetOrInsert(iter.Key()); + OriginBag& bag = copy.LookupOrInsert(iter.Key()); auto originIt = iter.Data().ConstIter(); for (; !originIt.Done(); originIt.Next()) { bag.Put(originIt.Key(), originIt.Data()); diff --git a/toolkit/components/telemetry/core/TelemetryScalar.cpp b/toolkit/components/telemetry/core/TelemetryScalar.cpp index b4564db116ac9..f0677623a1663 100644 --- a/toolkit/components/telemetry/core/TelemetryScalar.cpp +++ b/toolkit/components/telemetry/core/TelemetryScalar.cpp @@ -1515,8 +1515,8 @@ nsresult internal_GetScalarByEnum(const StaticMutexAutoLock& lock, // available. ScalarStorageMapType* const scalarStorage = processStorage - .GetOrInsertWith(storageId, - [] { return MakeUnique(); }) + .LookupOrInsertWith(storageId, + [] { return MakeUnique(); }) .get(); // Check if the scalar is already allocated in the parent or in the child @@ -1799,7 +1799,7 @@ nsresult internal_GetKeyedScalarByEnum(const StaticMutexAutoLock& lock, // available. KeyedScalarStorageMapType* const scalarStorage = processStorage - .GetOrInsertWith( + .LookupOrInsertWith( storageId, [] { return MakeUnique(); }) .get(); @@ -2000,7 +2000,7 @@ nsresult internal_ScalarSnapshotter(const StaticMutexAutoLock& aLock, for (auto iter = aProcessStorage.Iter(); !iter.Done(); iter.Next()) { ScalarStorageMapType* scalarStorage = iter.UserData(); ScalarTupleArray& processScalars = - aScalarsToReflect.GetOrInsert(iter.Key()); + aScalarsToReflect.LookupOrInsert(iter.Key()); // Are we in the "Dynamic" process? bool isDynamicProcess = @@ -2060,7 +2060,7 @@ nsresult internal_KeyedScalarSnapshotter( for (auto iter = aProcessStorage.Iter(); !iter.Done(); iter.Next()) { KeyedScalarStorageMapType* scalarStorage = iter.UserData(); KeyedScalarTupleArray& processScalars = - aScalarsToReflect.GetOrInsert(iter.Key()); + aScalarsToReflect.LookupOrInsert(iter.Key()); // Are we in the "Dynamic" process? bool isDynamicProcess = @@ -4003,7 +4003,7 @@ nsresult TelemetryScalar::DeserializePersistedScalars(JSContext* aCx, // Add the scalar to the map. PersistedScalarArray& processScalars = - scalarsToUpdate.GetOrInsert(static_cast(processID)); + scalarsToUpdate.LookupOrInsert(static_cast(processID)); processScalars.AppendElement(std::make_pair( nsCString(NS_ConvertUTF16toUTF8(scalarName)), unpackedVal)); } @@ -4175,7 +4175,7 @@ nsresult TelemetryScalar::DeserializePersistedKeyedScalars( // Add the scalar to the map. PersistedKeyedScalarArray& processScalars = - scalarsToUpdate.GetOrInsert(static_cast(processID)); + scalarsToUpdate.LookupOrInsert(static_cast(processID)); processScalars.AppendElement( mozilla::MakeTuple(nsCString(NS_ConvertUTF16toUTF8(scalarName)), nsString(keyName), unpackedVal)); diff --git a/toolkit/components/telemetry/geckoview/streaming/GeckoViewStreamingTelemetry.cpp b/toolkit/components/telemetry/geckoview/streaming/GeckoViewStreamingTelemetry.cpp index a52b5aadb0843..19ddd35ac3095 100644 --- a/toolkit/components/telemetry/geckoview/streaming/GeckoViewStreamingTelemetry.cpp +++ b/toolkit/components/telemetry/geckoview/streaming/GeckoViewStreamingTelemetry.cpp @@ -245,10 +245,10 @@ void HistogramAccumulate(const nsCString& aName, bool aIsCategorical, StaticMutexAutoLock lock(gMutex); if (aIsCategorical) { - nsTArray& samples = gCategoricalBatch.GetOrInsert(aName); + nsTArray& samples = gCategoricalBatch.LookupOrInsert(aName); samples.AppendElement(aValue); } else { - nsTArray& samples = gBatch.GetOrInsert(aName); + nsTArray& samples = gBatch.LookupOrInsert(aName); samples.AppendElement(aValue); } diff --git a/toolkit/xre/UntrustedModulesData.cpp b/toolkit/xre/UntrustedModulesData.cpp index 606069a0a9996..63f5530e27e99 100644 --- a/toolkit/xre/UntrustedModulesData.cpp +++ b/toolkit/xre/UntrustedModulesData.cpp @@ -318,7 +318,7 @@ void UntrustedModulesData::AddNewLoads( continue; } - Unused << mModules.GetOrInsert(iter.Key(), iter.Data()); + Unused << mModules.LookupOrInsert(iter.Key(), iter.Data()); } // This constant matches the maximum in Telemetry::CombinedStacks diff --git a/widget/android/EventDispatcher.cpp b/widget/android/EventDispatcher.cpp index d3d0315c10fca..ebfaca28bad5d 100644 --- a/widget/android/EventDispatcher.cpp +++ b/widget/android/EventDispatcher.cpp @@ -870,7 +870,8 @@ nsresult EventDispatcher::RegisterEventLocked( const nsAString& aEvent, nsIAndroidEventListener* aListener) { ListenersList* list = mListenersMap - .GetOrInsertWith(aEvent, [] { return MakeUnique(); }) + .LookupOrInsertWith(aEvent, + [] { return MakeUnique(); }) .get(); #ifdef DEBUG diff --git a/widget/gtk/WakeLockListener.cpp b/widget/gtk/WakeLockListener.cpp index f27f21e2eaa9c..86c17a9039a0d 100644 --- a/widget/gtk/WakeLockListener.cpp +++ b/widget/gtk/WakeLockListener.cpp @@ -484,7 +484,7 @@ nsresult WakeLockListener::Callback(const nsAString& topic, WakeLockTopic* const topicLock = mTopics - .GetOrInsertWith( + .LookupOrInsertWith( topic, [&] { return MakeUnique(topic, mConnection); }) .get(); diff --git a/xpcom/base/Logging.cpp b/xpcom/base/Logging.cpp index bfcef302a669b..2b3262bd82f56 100644 --- a/xpcom/base/Logging.cpp +++ b/xpcom/base/Logging.cpp @@ -534,11 +534,11 @@ class LogModuleManager { LogModule* CreateOrGetModule(const char* aName) { OffTheBooksMutexAutoLock guard(mModulesLock); return mModules - .GetOrInsertWith(aName, - [&] { - return UniquePtr( - new LogModule{aName, LogLevel::Disabled}); - }) + .LookupOrInsertWith(aName, + [&] { + return UniquePtr( + new LogModule{aName, LogLevel::Disabled}); + }) .get(); } diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index b2d0a8b7185f7..9686aaf1ba432 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -728,7 +728,7 @@ void nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& aCx, KnownModule* const km = mKnownModules - .GetOrInsertWith(hash, [&] { return MakeUnique(fl); }) + .LookupOrInsertWith(hash, [&] { return MakeUnique(fl); }) .get(); void* place = mArena.Allocate(sizeof(nsCID)); diff --git a/xpcom/ds/nsBaseHashtable.h b/xpcom/ds/nsBaseHashtable.h index 2fde710c40660..64b34a38f1901 100644 --- a/xpcom/ds/nsBaseHashtable.h +++ b/xpcom/ds/nsBaseHashtable.h @@ -192,11 +192,11 @@ class nsBaseHashtable * value. If aKey is not already in the table then the a default-constructed * or the provided value aData is used. * - * If the arguments are non-trivial to provide, consider using GetOrInsertWith - * instead. + * If the arguments are non-trivial to provide, consider using + * LookupOrInsertWith instead. */ template - DataType& GetOrInsert(const KeyType& aKey, Args&&... aArgs) { + DataType& LookupOrInsert(const KeyType& aKey, Args&&... aArgs) { return WithEntryHandle(aKey, [&](auto entryHandle) -> DataType& { return entryHandle.OrInsert(std::forward(aArgs)...); }); @@ -208,7 +208,7 @@ class nsBaseHashtable * constructed using the given factory. */ template - DataType& GetOrInsertWith(const KeyType& aKey, F&& aFunc) { + DataType& LookupOrInsertWith(const KeyType& aKey, F&& aFunc) { return WithEntryHandle(aKey, [&aFunc](auto entryHandle) -> DataType& { return entryHandle.OrInsertWith(std::forward(aFunc)); }); diff --git a/xpcom/ds/nsClassHashtable.h b/xpcom/ds/nsClassHashtable.h index c880569404459..ec81e4446f88d 100644 --- a/xpcom/ds/nsClassHashtable.h +++ b/xpcom/ds/nsClassHashtable.h @@ -95,11 +95,11 @@ template T* nsClassHashtable::GetOrInsertNew(KeyType aKey, Args&&... aConstructionArgs) { return this - ->GetOrInsertWith(std::move(aKey), - [&] { - return mozilla::MakeUnique( - std::forward(aConstructionArgs)...); - }) + ->LookupOrInsertWith(std::move(aKey), + [&] { + return mozilla::MakeUnique( + std::forward(aConstructionArgs)...); + }) .get(); } diff --git a/xpcom/tests/gtest/TestHashtables.cpp b/xpcom/tests/gtest/TestHashtables.cpp index 33776f4c99c72..805caf57300a1 100644 --- a/xpcom/tests/gtest/TestHashtables.cpp +++ b/xpcom/tests/gtest/TestHashtables.cpp @@ -373,7 +373,7 @@ struct DefaultConstructible_DefaultConstructible { static constexpr uint32_t kExpectedAddRefCnt_Get_OutputParam = 3; static constexpr uint32_t kExpectedAddRefCnt_Get = 3; static constexpr uint32_t kExpectedAddRefCnt_MaybeGet = 3; - static constexpr uint32_t kExpectedAddRefCnt_GetOrInsert = 1; + static constexpr uint32_t kExpectedAddRefCnt_LookupOrInsert = 1; static constexpr uint32_t kExpectedAddRefCnt_Put = 1; static constexpr uint32_t kExpectedAddRefCnt_Put_Fallible = 1; static constexpr uint32_t kExpectedAddRefCnt_Put_Rvalue = 1; @@ -684,55 +684,55 @@ TYPED_TEST_P(BaseHashtableTest, MaybeGet) { EXPECT_EQ(data.CharRef()->GetChar(), 42u); } -TYPED_TEST_P(BaseHashtableTest, GetOrInsert_Default) { +TYPED_TEST_P(BaseHashtableTest, LookupOrInsert_Default) { if constexpr (std::is_default_constructible_v) { auto table = MakeEmptyBaseHashtable(); - typename TypeParam::DataType& data = table.GetOrInsert(1); + typename TypeParam::DataType& data = table.LookupOrInsert(1); EXPECT_EQ(data.CharRef(), nullptr); data = typename TypeParam::DataType(MakeRefPtr( - 42, TypeParam::kExpectedAddRefCnt_GetOrInsert)); + 42, TypeParam::kExpectedAddRefCnt_LookupOrInsert)); } } -TYPED_TEST_P(BaseHashtableTest, GetOrInsert_NonDefault) { +TYPED_TEST_P(BaseHashtableTest, LookupOrInsert_NonDefault) { auto table = MakeEmptyBaseHashtable(); - typename TypeParam::DataType& data = table.GetOrInsert( + typename TypeParam::DataType& data = table.LookupOrInsert( 1, typename TypeParam::DataType{MakeRefPtr(42)}); EXPECT_NE(data.CharRef(), nullptr); } -TYPED_TEST_P(BaseHashtableTest, GetOrInsert_NonDefault_AlreadyPresent) { +TYPED_TEST_P(BaseHashtableTest, LookupOrInsert_NonDefault_AlreadyPresent) { auto table = MakeEmptyBaseHashtable(); - typename TypeParam::DataType& data1 = table.GetOrInsert( + typename TypeParam::DataType& data1 = table.LookupOrInsert( 1, typename TypeParam::DataType{MakeRefPtr(42)}); TestUniCharRefCounted* const address = data1.CharRef(); - typename TypeParam::DataType& data2 = table.GetOrInsert( + typename TypeParam::DataType& data2 = table.LookupOrInsert( 1, typename TypeParam::DataType{MakeRefPtr(42, 1)}); EXPECT_EQ(&data1, &data2); EXPECT_EQ(address, data2.CharRef()); } -TYPED_TEST_P(BaseHashtableTest, GetOrInsertWith) { +TYPED_TEST_P(BaseHashtableTest, LookupOrInsertWith) { auto table = MakeEmptyBaseHashtable(); - typename TypeParam::DataType& data = table.GetOrInsertWith(1, [] { + typename TypeParam::DataType& data = table.LookupOrInsertWith(1, [] { return typename TypeParam::DataType{MakeRefPtr(42)}; }); EXPECT_NE(data.CharRef(), nullptr); } -TYPED_TEST_P(BaseHashtableTest, GetOrInsertWith_AlreadyPresent) { +TYPED_TEST_P(BaseHashtableTest, LookupOrInsertWith_AlreadyPresent) { auto table = MakeEmptyBaseHashtable(); - table.GetOrInsertWith(1, [] { + table.LookupOrInsertWith(1, [] { return typename TypeParam::DataType{MakeRefPtr(42)}; }); - table.GetOrInsertWith(1, [] { + table.LookupOrInsertWith(1, [] { ADD_FAILURE(); return typename TypeParam::DataType{MakeRefPtr(42)}; }); @@ -992,9 +992,9 @@ TYPED_TEST_P(BaseHashtableTest, MarkImmutable) { REGISTER_TYPED_TEST_CASE_P( BaseHashtableTest, Contains, GetGeneration, SizeOfExcludingThis, SizeOfIncludingThis, Count, IsEmpty, Get_OutputParam, Get, MaybeGet, - GetOrInsert_Default, GetOrInsert_NonDefault, - GetOrInsert_NonDefault_AlreadyPresent, GetOrInsertWith, - GetOrInsertWith_AlreadyPresent, Put, Put_Fallible, Put_Rvalue, + LookupOrInsert_Default, LookupOrInsert_NonDefault, + LookupOrInsert_NonDefault_AlreadyPresent, LookupOrInsertWith, + LookupOrInsertWith_AlreadyPresent, Put, Put_Fallible, Put_Rvalue, Put_Rvalue_Fallible, Remove_OutputParam, Remove, Extract, RemoveIf, Lookup, Lookup_Remove, WithEntryHandle_NoOp, WithEntryHandle_NotFound_OrInsert, WithEntryHandle_NotFound_OrInsertFrom, @@ -1464,7 +1464,7 @@ TEST(Hashtables, ClassHashtable_GetOrInsertNew_NotPresent) EXPECT_EQ(42u, entry->GetChar()); } -TEST(Hashtables, ClassHashtable_GetOrInsertWith_Present) +TEST(Hashtables, ClassHashtable_LookupOrInsertWith_Present) { nsClassHashtable EntToUniClass(ENTITY_COUNT); @@ -1473,17 +1473,17 @@ TEST(Hashtables, ClassHashtable_GetOrInsertWith_Present) mozilla::MakeUnique(entity.mUnicode)); } - const auto& entry = EntToUniClass.GetOrInsertWith( + const auto& entry = EntToUniClass.LookupOrInsertWith( "uml"_ns, [] { return mozilla::MakeUnique(42); }); EXPECT_EQ(168u, entry->GetChar()); } -TEST(Hashtables, ClassHashtable_GetOrInsertWith_NotPresent) +TEST(Hashtables, ClassHashtable_LookupOrInsertWith_NotPresent) { nsClassHashtable EntToUniClass(ENTITY_COUNT); // This is going to insert a TestUniCharDerived. - const auto& entry = EntToUniClass.GetOrInsertWith( + const auto& entry = EntToUniClass.LookupOrInsertWith( "uml"_ns, [] { return mozilla::MakeUnique(42); }); EXPECT_EQ(42u, entry->GetChar()); }