Skip to content

Commit

Permalink
Bug 1693541 - Improve uses of nsBaseHashtable and descendants and avo…
Browse files Browse the repository at this point in the history
…id multiple subsequent lookups in dom/presentation/ipc. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D106118
  • Loading branch information
sigiesec committed Mar 2, 2021
1 parent 0246306 commit 19958df
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dom/presentation/ipc/PresentationIPCService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ PresentationIPCService::RegisterSessionListener(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aListener);

nsCOMPtr<nsIPresentationSessionListener> listener;
if (mSessionListeners.Get(aSessionId, getter_AddRefs(listener))) {
mSessionListeners.InsertOrUpdate(aSessionId, RefPtr{aListener});
return NS_OK;
}

mSessionListeners.InsertOrUpdate(aSessionId, RefPtr{aListener});
if (sPresentationChild) {
bool hadEntry =
mSessionListeners.WithEntryHandle(aSessionId, [&](auto&& entry) {
const bool hadEntry = entry.HasEntry();
entry.InsertOrUpdate(RefPtr{aListener});
return hadEntry;
});

if (!hadEntry && sPresentationChild) {
Unused << NS_WARN_IF(!sPresentationChild->SendRegisterSessionHandler(
nsString(aSessionId), aRole));
}
Expand Down

0 comments on commit 19958df

Please sign in to comment.