Bug 1634281 - Use nsBaseHashtable::GetOrInsertNew where possible. r=xpcom-reviewers,nika

Differential Revision: https://phabricator.services.mozilla.com/D106491
This commit is contained in:
Simon Giesecke 2021-03-03 08:58:52 +00:00
parent b5855b89fc
commit 4ff9d15889
7 changed files with 7 additions and 15 deletions

View File

@ -140,8 +140,7 @@ void DocManager::NotifyOfRemoteDocShutdown(DocAccessibleParent* aDoc) {
xpcAccessibleDocument* DocManager::GetXPCDocument(DocAccessible* aDocument) {
if (!aDocument) return nullptr;
return mXPCDocumentCache.LookupOrInsertWith(
aDocument, [&] { return MakeRefPtr<xpcAccessibleDocument>(aDocument); });
return mXPCDocumentCache.GetOrInsertNew(aDocument, aDocument);
}
xpcAccessibleDocument* DocManager::GetXPCDocument(DocAccessibleParent* aDoc) {

View File

@ -4713,10 +4713,7 @@ OverOutElementsWrapper* EventStateManager::GetWrapperByEventID(
}
return mMouseEnterLeaveHelper;
}
return mPointersEnterLeaveHelper
.LookupOrInsertWith(pointer->pointerId,
[] { return new OverOutElementsWrapper(); })
.get();
return mPointersEnterLeaveHelper.GetOrInsertNew(pointer->pointerId);
}
/* static */

View File

@ -104,8 +104,7 @@ bool MediaPlaybackStatus::IsAnyMediaBeingControlled() const {
MediaPlaybackStatus::ContextMediaInfo&
MediaPlaybackStatus::GetNotNullContextInfo(uint64_t aContextId) {
MOZ_ASSERT(NS_IsMainThread());
return *mContextInfoMap.LookupOrInsertWith(
aContextId, [&] { return MakeUnique<ContextMediaInfo>(aContextId); });
return *mContextInfoMap.GetOrInsertNew(aContextId, aContextId);
}
Maybe<uint64_t> MediaPlaybackStatus::GetAudioFocusOwnerContextId() const {

View File

@ -41,8 +41,7 @@ PluginScriptableObjectChild::IdentifierTable
/* static */ PluginScriptableObjectChild::StoredIdentifier*
PluginScriptableObjectChild::HashIdentifier(const nsCString& aIdentifier) {
return sIdentifiers.LookupOrInsertWith(
aIdentifier, [&] { return MakeRefPtr<StoredIdentifier>(aIdentifier); });
return sIdentifiers.GetOrInsertNew(aIdentifier, aIdentifier);
}
/* static */

View File

@ -1594,8 +1594,7 @@ ServiceWorkerManager::GetOrCreateJobQueue(const nsACString& aKey,
.get();
}
RefPtr queue = data->mJobQueues.LookupOrInsertWith(
aScope, [] { return new ServiceWorkerJobQueue(); });
RefPtr queue = data->mJobQueues.GetOrInsertNew(aScope);
return queue.forget();
}

View File

@ -1018,8 +1018,7 @@ gfxUserFontFamily* gfxUserFontSet::GetFamily(const nsACString& aFamilyName) {
nsAutoCString key(aFamilyName);
ToLowerCase(key);
return mFontFamilies.LookupOrInsertWith(
key, [&] { return MakeRefPtr<gfxUserFontFamily>(aFamilyName); });
return mFontFamilies.GetOrInsertNew(key, aFamilyName);
}
void gfxUserFontSet::ForgetLocalFaces() {

View File

@ -137,7 +137,7 @@ NS_IMPL_ISUPPORTS(TimerKeys, TimerKeys)
Timer* TimerKeys::Get(const nsAString& aKey, bool aCreate) {
if (aCreate) {
return mTimers.LookupOrInsertWith(aKey, [] { return new Timer(); });
return mTimers.GetOrInsertNew(aKey);
}
return mTimers.GetWeak(aKey);
}