mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1693306 - Simplify some uses of LookupOrInsertWith by GetOrInsertNew. r=xpcom-reviewers,necko-reviewers,dragana,nika
Differential Revision: https://phabricator.services.mozilla.com/D105479
This commit is contained in:
parent
be7dc83fa6
commit
0b443059fd
@ -164,15 +164,9 @@ inline DocAccessible::AttrRelProviders* DocAccessible::GetOrCreateRelProviders(
|
||||
dom::DocumentOrShadowRoot* docOrShadowRoot =
|
||||
aElement->GetUncomposedDocOrConnectedShadowRoot();
|
||||
DependentIDsHashtable* hash =
|
||||
mDependentIDsHashes
|
||||
.LookupOrInsertWith(
|
||||
docOrShadowRoot,
|
||||
[] { return MakeUnique<DependentIDsHashtable>(); })
|
||||
.get();
|
||||
mDependentIDsHashes.GetOrInsertNew(docOrShadowRoot);
|
||||
|
||||
return hash
|
||||
->LookupOrInsertWith(aID, [] { return MakeUnique<AttrRelProviders>(); })
|
||||
.get();
|
||||
return hash->GetOrInsertNew(aID);
|
||||
}
|
||||
|
||||
inline void DocAccessible::RemoveRelProvidersIfEmpty(dom::Element* aElement,
|
||||
|
@ -752,10 +752,7 @@ nsRadioGroupStruct* DocumentOrShadowRoot::GetRadioGroup(
|
||||
|
||||
nsRadioGroupStruct* DocumentOrShadowRoot::GetOrCreateRadioGroup(
|
||||
const nsAString& aName) {
|
||||
return mRadioGroups
|
||||
.LookupOrInsertWith(aName,
|
||||
[] { return MakeUnique<nsRadioGroupStruct>(); })
|
||||
.get();
|
||||
return mRadioGroups.GetOrInsertNew(aName);
|
||||
}
|
||||
|
||||
int32_t DocumentOrShadowRoot::StyleOrderIndexOfSheet(
|
||||
|
@ -201,11 +201,7 @@ EventSourceEventService::AddListener(uint64_t aInnerWindowID,
|
||||
}
|
||||
++mCountListeners;
|
||||
|
||||
WindowListener* listener =
|
||||
mWindows
|
||||
.LookupOrInsertWith(aInnerWindowID,
|
||||
[] { return MakeUnique<WindowListener>(); })
|
||||
.get();
|
||||
WindowListener* listener = mWindows.GetOrInsertNew(aInnerWindowID);
|
||||
|
||||
listener->mListeners.AppendElement(aListener);
|
||||
|
||||
|
@ -1039,11 +1039,7 @@ void nsAutoMutationBatch::Done() {
|
||||
|
||||
if (allObservers.Length()) {
|
||||
auto* const transientReceivers =
|
||||
ob->mTransientReceivers
|
||||
.LookupOrInsertWith(
|
||||
removed,
|
||||
[] { return MakeUnique<nsCOMArray<nsMutationReceiver>>(); })
|
||||
.get();
|
||||
ob->mTransientReceivers.GetOrInsertNew(removed);
|
||||
for (uint32_t k = 0; k < allObservers.Length(); ++k) {
|
||||
nsMutationReceiver* r = allObservers[k];
|
||||
nsMutationReceiver* orig = r->GetParent() ? r->GetParent() : r;
|
||||
|
@ -239,15 +239,7 @@ void nsFrameMessageManager::AddMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
bool aListenWhenClosed,
|
||||
ErrorResult& aError) {
|
||||
auto* const listeners =
|
||||
mListeners
|
||||
.LookupOrInsertWith(
|
||||
aMessageName,
|
||||
[] {
|
||||
return MakeUnique<
|
||||
nsAutoTObserverArray<nsMessageListenerInfo, 1>>();
|
||||
})
|
||||
.get();
|
||||
auto* const listeners = mListeners.GetOrInsertNew(aMessageName);
|
||||
uint32_t len = listeners->Length();
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
MessageListener* strongListener = listeners->ElementAt(i).mStrongListener;
|
||||
@ -314,15 +306,7 @@ void nsFrameMessageManager::AddWeakMessageListener(
|
||||
}
|
||||
#endif
|
||||
|
||||
auto* const listeners =
|
||||
mListeners
|
||||
.LookupOrInsertWith(
|
||||
aMessageName,
|
||||
[] {
|
||||
return MakeUnique<
|
||||
nsAutoTObserverArray<nsMessageListenerInfo, 1>>();
|
||||
})
|
||||
.get();
|
||||
auto* const listeners = mListeners.GetOrInsertNew(aMessageName);
|
||||
uint32_t len = listeners->Length();
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
if (listeners->ElementAt(i).mWeakListener == weak) {
|
||||
|
@ -81,12 +81,7 @@ void BroadcastChannelService::RegisterActor(
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
auto* const parents =
|
||||
mAgents
|
||||
.LookupOrInsertWith(
|
||||
aOriginChannelKey,
|
||||
[] { return MakeUnique<nsTArray<BroadcastChannelParent*>>(); })
|
||||
.get();
|
||||
auto* const parents = mAgents.GetOrInsertNew(aOriginChannelKey);
|
||||
|
||||
MOZ_ASSERT(!parents->Contains(aParent));
|
||||
parents->AppendElement(aParent);
|
||||
|
@ -81,11 +81,7 @@ nsCommandManager::AddCommandObserver(nsIObserver* aCommandObserver,
|
||||
|
||||
// for each command in the table, we make a list of observers for that command
|
||||
auto* const commandObservers =
|
||||
mObserversTable
|
||||
.LookupOrInsertWith(
|
||||
aCommandToObserve,
|
||||
[] { return mozilla::MakeUnique<ObserverList>(); })
|
||||
.get();
|
||||
mObserversTable.GetOrInsertNew(aCommandToObserve);
|
||||
|
||||
// need to check that this command observer hasn't already been registered
|
||||
int32_t existingIndex = commandObservers->IndexOf(aCommandObserver);
|
||||
|
@ -7627,13 +7627,7 @@ nsresult DatabaseConnection::UpdateRefcountFunction::ProcessValue(
|
||||
MOZ_ASSERT(id > 0);
|
||||
|
||||
const auto entry =
|
||||
WrapNotNull(mFileInfoEntries
|
||||
.LookupOrInsertWith(id,
|
||||
[&file] {
|
||||
return MakeUnique<FileInfoEntry>(
|
||||
file.FileInfoPtr());
|
||||
})
|
||||
.get());
|
||||
WrapNotNull(mFileInfoEntries.GetOrInsertNew(id, file.FileInfoPtr()));
|
||||
|
||||
if (mInSavepoint) {
|
||||
mSavepointEntriesIndex.InsertOrUpdate(id, entry);
|
||||
|
@ -3228,11 +3228,7 @@ bool RecvPBackgroundLSObserverConstructor(PBackgroundLSObserverParent* aActor,
|
||||
const auto notNullObserver = WrapNotNull(observer.get());
|
||||
|
||||
nsTArray<NotNull<Observer*>>* const array =
|
||||
gObservers
|
||||
->LookupOrInsertWith(
|
||||
notNullObserver->Origin(),
|
||||
[] { return MakeUnique<nsTArray<NotNull<Observer*>>>(); })
|
||||
.get();
|
||||
gObservers->GetOrInsertNew(notNullObserver->Origin());
|
||||
array->AppendElement(notNullObserver);
|
||||
|
||||
if (RefPtr<Datastore> datastore = GetDatastore(observer->Origin())) {
|
||||
|
@ -2792,11 +2792,7 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
|
||||
// Add a WindowID cross-reference so OnNavigation can tear
|
||||
// things down
|
||||
nsTArray<nsString>* const array =
|
||||
self->mCallIds
|
||||
.LookupOrInsertWith(
|
||||
windowID,
|
||||
[] { return MakeUnique<nsTArray<nsString>>(); })
|
||||
.get();
|
||||
self->mCallIds.GetOrInsertNew(windowID);
|
||||
array->AppendElement(callID);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
|
@ -13,10 +13,7 @@ class GMPMemoryStorage : public GMPStorage {
|
||||
GMPErr Open(const nsCString& aRecordName) override {
|
||||
MOZ_ASSERT(!IsOpen(aRecordName));
|
||||
|
||||
Record* record = mRecords
|
||||
.LookupOrInsertWith(
|
||||
aRecordName, [] { return MakeUnique<Record>(); })
|
||||
.get();
|
||||
Record* record = mRecords.GetOrInsertNew(aRecordName);
|
||||
record->mIsOpen = true;
|
||||
return GMPNoErr;
|
||||
}
|
||||
|
@ -79,10 +79,8 @@ class PresentationServiceBase {
|
||||
return;
|
||||
}
|
||||
|
||||
mRespondingSessionIds
|
||||
.LookupOrInsertWith(aWindowId,
|
||||
[] { return MakeUnique<nsTArray<nsString>>(); })
|
||||
->AppendElement(nsString(aSessionId));
|
||||
mRespondingSessionIds.GetOrInsertNew(aWindowId)->AppendElement(
|
||||
nsString(aSessionId));
|
||||
mRespondingWindowIds.InsertOrUpdate(aSessionId, aWindowId);
|
||||
}
|
||||
|
||||
@ -227,10 +225,8 @@ class PresentationServiceBase {
|
||||
for (uint32_t i = 0; i < entry->mListeners.Length(); ++i) {
|
||||
nsIPresentationAvailabilityListener* listener =
|
||||
entry->mListeners.ObjectAt(i);
|
||||
availabilityListenerTable
|
||||
.LookupOrInsertWith(
|
||||
listener, [] { return MakeUnique<nsTArray<nsString>>(); })
|
||||
->AppendElement(it.Key());
|
||||
availabilityListenerTable.GetOrInsertNew(listener)->AppendElement(
|
||||
it.Key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6674,11 +6674,7 @@ already_AddRefed<GroupInfo> QuotaManager::LockedGetOrCreateGroupInfo(
|
||||
mQuotaMutex.AssertCurrentThreadOwns();
|
||||
MOZ_ASSERT(aPersistenceType != PERSISTENCE_TYPE_PERSISTENT);
|
||||
|
||||
GroupInfoPair* const pair =
|
||||
mGroupInfoPairs
|
||||
.LookupOrInsertWith(aGroup,
|
||||
[] { return MakeUnique<GroupInfoPair>(); })
|
||||
.get();
|
||||
GroupInfoPair* const pair = mGroupInfoPairs.GetOrInsertNew(aGroup);
|
||||
|
||||
RefPtr<GroupInfo> groupInfo = pair->LockedGetGroupInfo(aPersistenceType);
|
||||
if (!groupInfo) {
|
||||
|
@ -1906,12 +1906,7 @@ void ServiceWorkerManager::AddScopeAndRegistration(
|
||||
|
||||
MOZ_ASSERT(!scopeKey.IsEmpty());
|
||||
|
||||
auto* const data =
|
||||
swm->mRegistrationInfos
|
||||
.LookupOrInsertWith(
|
||||
scopeKey,
|
||||
[] { return MakeUnique<RegistrationDataPerPrincipal>(); })
|
||||
.get();
|
||||
auto* const data = swm->mRegistrationInfos.GetOrInsertNew(scopeKey);
|
||||
|
||||
data->mScopeContainer.InsertScope(aScope);
|
||||
data->mInfos.InsertOrUpdate(aScope, RefPtr{aInfo});
|
||||
|
@ -1463,11 +1463,7 @@ mozilla::ipc::IPCResult RecvPBackgroundLocalStorageCacheConstructor(
|
||||
gLocalStorageCacheParents = new LocalStorageCacheParentHashtable();
|
||||
}
|
||||
|
||||
gLocalStorageCacheParents
|
||||
->LookupOrInsertWith(
|
||||
aOriginKey,
|
||||
[] { return MakeUnique<nsTArray<LocalStorageCacheParent*>>(); })
|
||||
->AppendElement(actor);
|
||||
gLocalStorageCacheParents->GetOrInsertNew(aOriginKey)->AppendElement(actor);
|
||||
|
||||
// We are currently trusting the content process not to lie to us. It is
|
||||
// future work to consult the ClientManager to determine whether this is a
|
||||
|
@ -1222,12 +1222,7 @@ bool RuntimeService::RegisterWorker(WorkerPrivate& aWorkerPrivate) {
|
||||
if (!isServiceWorker) {
|
||||
// Service workers are excluded since their lifetime is separate from
|
||||
// that of dom windows.
|
||||
if (auto* const windowArray =
|
||||
mWindowMap
|
||||
.LookupOrInsertWith(
|
||||
window,
|
||||
[] { return MakeUnique<nsTArray<WorkerPrivate*>>(1); })
|
||||
.get();
|
||||
if (auto* const windowArray = mWindowMap.GetOrInsertNew(window, 1);
|
||||
!windowArray->Contains(&aWorkerPrivate)) {
|
||||
windowArray->AppendElement(&aWorkerPrivate);
|
||||
} else {
|
||||
|
@ -10551,11 +10551,7 @@ void ReflowCountMgr::Add(const char* aName, nsIFrame* aFrame) {
|
||||
NS_ASSERTION(aName != nullptr, "Name shouldn't be null!");
|
||||
|
||||
if (mDumpFrameCounts) {
|
||||
auto* const counter =
|
||||
mCounts
|
||||
.LookupOrInsertWith(
|
||||
aName, [this] { return MakeUnique<ReflowCounter>(this); })
|
||||
.get();
|
||||
auto* const counter = mCounts.GetOrInsertNew(aName, this);
|
||||
counter->Add();
|
||||
}
|
||||
|
||||
|
@ -308,10 +308,7 @@ bool nsCounterManager::AddCounterChanges(nsIFrame* aFrame) {
|
||||
|
||||
nsCounterList* nsCounterManager::CounterListFor(nsAtom* aCounterName) {
|
||||
MOZ_ASSERT(aCounterName);
|
||||
return mNames
|
||||
.LookupOrInsertWith(aCounterName,
|
||||
[] { return MakeUnique<nsCounterList>(); })
|
||||
.get();
|
||||
return mNames.GetOrInsertNew(aCounterName);
|
||||
}
|
||||
|
||||
void nsCounterManager::RecalcAll() {
|
||||
|
@ -1354,11 +1354,7 @@ bool nsRefreshDriver::AddImageRequest(imgIRequest* aRequest) {
|
||||
if (delay == 0) {
|
||||
mRequests.PutEntry(aRequest);
|
||||
} else {
|
||||
auto* const start =
|
||||
mStartTable
|
||||
.LookupOrInsertWith(delay,
|
||||
[] { return MakeUnique<ImageStartData>(); })
|
||||
.get();
|
||||
auto* const start = mStartTable.GetOrInsertNew(delay);
|
||||
start->mEntries.PutEntry(aRequest);
|
||||
}
|
||||
|
||||
|
@ -2029,9 +2029,10 @@ void SelectionRangeState::SelectNodesExceptInSubtree(const Position& aStart,
|
||||
static constexpr auto kEllipsis = u"\x2026"_ns;
|
||||
|
||||
nsINode* root = aStart.mNode->SubtreeRoot();
|
||||
auto& start = mPositions.LookupOrInsertWith(root, [&] {
|
||||
return Position{root, 0};
|
||||
});
|
||||
auto& start =
|
||||
mPositions.WithEntryHandle(root, [&](auto&& entry) -> Position& {
|
||||
return entry.OrInsertWith([&] { return Position{root, 0}; });
|
||||
});
|
||||
|
||||
bool ellipsizedStart = false;
|
||||
if (auto* text = Text::FromNode(aStart.mNode)) {
|
||||
|
@ -440,8 +440,7 @@ already_AddRefed<imgRequestProxy> ImageLoader::LoadImage(
|
||||
if (NS_FAILED(rv) || !request) {
|
||||
return nullptr;
|
||||
}
|
||||
sImages->LookupOrInsertWith(request,
|
||||
[] { return MakeUnique<ImageTableEntry>(); });
|
||||
sImages->GetOrInsertNew(request);
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
|
@ -106,9 +106,7 @@ ShadowParts ShadowParts::Parse(const nsAString& aString) {
|
||||
continue;
|
||||
}
|
||||
nsAtom* second = mapping.second.get();
|
||||
parts.mMappings
|
||||
.LookupOrInsertWith(mapping.first,
|
||||
[] { return MakeUnique<PartList>(); })
|
||||
parts.mMappings.GetOrInsertNew(mapping.first)
|
||||
->AppendElement(std::move(mapping.second));
|
||||
parts.mReverseMappings.InsertOrUpdate(second, std::move(mapping.first));
|
||||
}
|
||||
|
@ -2195,9 +2195,7 @@ void CacheFile::QueueChunkListener(uint32_t aIndex,
|
||||
}
|
||||
item->mCallback = aCallback;
|
||||
|
||||
mChunkListeners
|
||||
.LookupOrInsertWith(aIndex, [] { return MakeUnique<ChunkListeners>(); })
|
||||
->mItems.AppendElement(item);
|
||||
mChunkListeners.GetOrInsertNew(aIndex)->mItems.AppendElement(item);
|
||||
}
|
||||
|
||||
nsresult CacheFile::NotifyChunkListeners(uint32_t aIndex, nsresult aResult,
|
||||
|
@ -135,11 +135,7 @@ nsresult ChildDNSService::AsyncResolveInternal(
|
||||
nsCString key;
|
||||
GetDNSRecordHashKey(hostname, DNSResolverInfo::URL(aResolver), type,
|
||||
aOriginAttributes, flags, originalListenerAddr, key);
|
||||
mPendingRequests
|
||||
.LookupOrInsertWith(
|
||||
key,
|
||||
[] { return MakeUnique<nsTArray<RefPtr<DNSRequestSender>>>(); })
|
||||
->AppendElement(sender);
|
||||
mPendingRequests.GetOrInsertNew(key)->AppendElement(sender);
|
||||
}
|
||||
|
||||
sender->StartRequest();
|
||||
|
@ -860,8 +860,7 @@ nsresult DNSPacket::DecodeInternal(
|
||||
|
||||
auto parseRecord = [&]() {
|
||||
LOG(("Parsing additional record type: %u", type));
|
||||
auto& entry = aAdditionalRecords.LookupOrInsertWith(
|
||||
qname, [] { return MakeUnique<DOHresp>(); });
|
||||
auto* entry = aAdditionalRecords.GetOrInsertNew(qname);
|
||||
|
||||
switch (type) {
|
||||
case TRRTYPE_A:
|
||||
|
@ -1434,9 +1434,7 @@ nsDNSService::ReportFailedSVCDomainName(const nsACString& aOwnerName,
|
||||
const nsACString& aSVCDomainName) {
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
mFailedSVCDomainNames
|
||||
.LookupOrInsertWith(aOwnerName,
|
||||
[] { return MakeUnique<nsTArray<nsCString>>(1); })
|
||||
mFailedSVCDomainNames.GetOrInsertNew(aOwnerName, 1)
|
||||
->AppendElement(aSVCDomainName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -57,14 +57,11 @@ void PendingTransactionQueue::InsertTransactionNormal(
|
||||
|
||||
uint64_t windowId = TabIdForQueuing(info->Transaction());
|
||||
nsTArray<RefPtr<PendingTransactionInfo>>* const infoArray =
|
||||
mPendingTransactionTable
|
||||
.LookupOrInsertWith(
|
||||
windowId,
|
||||
[] {
|
||||
return MakeUnique<nsTArray<RefPtr<PendingTransactionInfo>>>();
|
||||
})
|
||||
.get();
|
||||
mPendingTransactionTable.GetOrInsertNew(windowId);
|
||||
|
||||
// XXX At least if a new array was empty before, this isn't efficient, as it
|
||||
// does an insert-sort. It would be better to just append all elements and
|
||||
// then sort.
|
||||
InsertTransactionSorted(*infoArray, info, aInsertAsFirstForTheSamePriority);
|
||||
}
|
||||
|
||||
|
@ -3344,11 +3344,8 @@ void nsHttpConnectionMgr::RegisterOriginCoalescingKey(HttpConnectionBase* conn,
|
||||
|
||||
nsCString newKey;
|
||||
BuildOriginFrameHashKey(newKey, ci, host, port);
|
||||
mCoalescingHash
|
||||
.LookupOrInsertWith(newKey,
|
||||
[] { return MakeUnique<nsTArray<nsWeakPtr>>(1); })
|
||||
->AppendElement(
|
||||
do_GetWeakReference(static_cast<nsISupportsWeakReference*>(conn)));
|
||||
mCoalescingHash.GetOrInsertNew(newKey, 1)->AppendElement(
|
||||
do_GetWeakReference(static_cast<nsISupportsWeakReference*>(conn)));
|
||||
|
||||
LOG(
|
||||
("nsHttpConnectionMgr::RegisterOriginCoalescingKey "
|
||||
|
@ -119,14 +119,9 @@ nsresult nsStreamConverterService::AddAdjacency(const char* aContractID) {
|
||||
// each MIME-type is represented as a key in our hashtable.
|
||||
|
||||
nsTArray<RefPtr<nsAtom>>* const fromEdges =
|
||||
mAdjacencyList
|
||||
.LookupOrInsertWith(
|
||||
fromStr,
|
||||
[] { return mozilla::MakeUnique<nsTArray<RefPtr<nsAtom>>>(); })
|
||||
.get();
|
||||
mAdjacencyList.GetOrInsertNew(fromStr);
|
||||
|
||||
mozilla::Unused << mAdjacencyList.LookupOrInsertWith(
|
||||
toStr, [] { return mozilla::MakeUnique<nsTArray<RefPtr<nsAtom>>>(); });
|
||||
mAdjacencyList.GetOrInsertNew(toStr);
|
||||
|
||||
// Now we know the FROM and TO types are represented as keys in the hashtable.
|
||||
// Let's "connect" the verticies, making an edge.
|
||||
|
@ -1098,10 +1098,7 @@ void NativeFileWatcherIOTask::AppendCallbacksToHashtables(
|
||||
const nsMainThreadPtrHandle<nsINativeFileWatcherErrorCallback>&
|
||||
aOnErrorHandle) {
|
||||
ChangeCallbackArray* const callbacksArray =
|
||||
mChangeCallbacksTable
|
||||
.LookupOrInsertWith(aPath,
|
||||
[] { return MakeUnique<ChangeCallbackArray>(); })
|
||||
.get();
|
||||
mChangeCallbacksTable.GetOrInsertNew(aPath);
|
||||
|
||||
// Now we do have an entry for that path. Check to see if the callback is
|
||||
// already there.
|
||||
@ -1115,10 +1112,7 @@ void NativeFileWatcherIOTask::AppendCallbacksToHashtables(
|
||||
|
||||
// Same thing for the error callback.
|
||||
ErrorCallbackArray* const errorCallbacksArray =
|
||||
mErrorCallbacksTable
|
||||
.LookupOrInsertWith(aPath,
|
||||
[] { return MakeUnique<ErrorCallbackArray>(); })
|
||||
.get();
|
||||
mErrorCallbacksTable.GetOrInsertNew(aPath);
|
||||
|
||||
ErrorCallbackArray::index_type errorCallbackIndex =
|
||||
errorCallbacksArray->IndexOf(aOnErrorHandle);
|
||||
|
@ -375,10 +375,7 @@ bool IsExpired(const EventKey& key) { return key.id == kExpiredEventId; }
|
||||
|
||||
EventRecordArray* GetEventRecordsForProcess(const StaticMutexAutoLock& lock,
|
||||
ProcessID processType) {
|
||||
return gEventRecords
|
||||
.LookupOrInsertWith(uint32_t(processType),
|
||||
[] { return MakeUnique<EventRecordArray>(); })
|
||||
.get();
|
||||
return gEventRecords.GetOrInsertNew(uint32_t(processType));
|
||||
}
|
||||
|
||||
EventKey* GetEventKey(const StaticMutexAutoLock& lock,
|
||||
|
@ -1514,10 +1514,7 @@ nsresult internal_GetScalarByEnum(const StaticMutexAutoLock& lock,
|
||||
// Get the process-specific storage or create one if it's not
|
||||
// available.
|
||||
ScalarStorageMapType* const scalarStorage =
|
||||
processStorage
|
||||
.LookupOrInsertWith(storageId,
|
||||
[] { return MakeUnique<ScalarStorageMapType>(); })
|
||||
.get();
|
||||
processStorage.GetOrInsertNew(storageId);
|
||||
|
||||
// Check if the scalar is already allocated in the parent or in the child
|
||||
// storage.
|
||||
@ -1798,10 +1795,7 @@ nsresult internal_GetKeyedScalarByEnum(const StaticMutexAutoLock& lock,
|
||||
// Get the process-specific storage or create one if it's not
|
||||
// available.
|
||||
KeyedScalarStorageMapType* const scalarStorage =
|
||||
processStorage
|
||||
.LookupOrInsertWith(
|
||||
storageId, [] { return MakeUnique<KeyedScalarStorageMapType>(); })
|
||||
.get();
|
||||
processStorage.GetOrInsertNew(storageId);
|
||||
|
||||
if (scalarStorage->Get(aId.id, &scalar)) {
|
||||
*aRet = scalar;
|
||||
|
@ -868,11 +868,7 @@ nsresult EventDispatcher::IterateEvents(JSContext* aCx, JS::HandleValue aEvents,
|
||||
|
||||
nsresult EventDispatcher::RegisterEventLocked(
|
||||
const nsAString& aEvent, nsIAndroidEventListener* aListener) {
|
||||
ListenersList* list =
|
||||
mListenersMap
|
||||
.LookupOrInsertWith(aEvent,
|
||||
[] { return MakeUnique<ListenersList>(); })
|
||||
.get();
|
||||
ListenersList* list = mListenersMap.GetOrInsertNew(aEvent);
|
||||
|
||||
#ifdef DEBUG
|
||||
for (ssize_t i = 0; i < list->listeners.Count(); i++) {
|
||||
|
@ -483,11 +483,7 @@ nsresult WakeLockListener::Callback(const nsAString& topic,
|
||||
return NS_OK;
|
||||
|
||||
WakeLockTopic* const topicLock =
|
||||
mTopics
|
||||
.LookupOrInsertWith(
|
||||
topic,
|
||||
[&] { return MakeUnique<WakeLockTopic>(topic, mConnection); })
|
||||
.get();
|
||||
mTopics.GetOrInsertNew(topic, topic, mConnection);
|
||||
|
||||
// Treat "locked-background" the same as "unlocked" on desktop linux.
|
||||
bool shouldLock = state.EqualsLiteral("locked-foreground");
|
||||
|
@ -726,10 +726,7 @@ void nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& aCx,
|
||||
return;
|
||||
}
|
||||
|
||||
KnownModule* const km =
|
||||
mKnownModules
|
||||
.LookupOrInsertWith(hash, [&] { return MakeUnique<KnownModule>(fl); })
|
||||
.get();
|
||||
KnownModule* const km = mKnownModules.GetOrInsertNew(hash, fl);
|
||||
|
||||
void* place = mArena.Allocate(sizeof(nsCID));
|
||||
nsID* permanentCID = static_cast<nsID*>(place);
|
||||
|
Loading…
Reference in New Issue
Block a user