mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1634281
- Use nsBaseHashtable::GetOrInsertNew where possible. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D106491
This commit is contained in:
parent
b5855b89fc
commit
4ff9d15889
@ -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) {
|
||||
|
@ -4713,10 +4713,7 @@ OverOutElementsWrapper* EventStateManager::GetWrapperByEventID(
|
||||
}
|
||||
return mMouseEnterLeaveHelper;
|
||||
}
|
||||
return mPointersEnterLeaveHelper
|
||||
.LookupOrInsertWith(pointer->pointerId,
|
||||
[] { return new OverOutElementsWrapper(); })
|
||||
.get();
|
||||
return mPointersEnterLeaveHelper.GetOrInsertNew(pointer->pointerId);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -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 {
|
||||
|
@ -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 */
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user