Bug 1372262 - Use LookupForAdd instead of Get+Put to avoid unnecessary hashtable lookups. r=froydnj

MozReview-Commit-ID: 5LmOqXRgo25
This commit is contained in:
Mats Palmgren 2017-06-14 16:11:21 +02:00
Родитель 2c6dbe5497
Коммит 893dffd030
1 изменённых файлов: 8 добавлений и 11 удалений

Просмотреть файл

@ -14524,18 +14524,15 @@ nsGlobalWindow::GetGroupMessageManager(const nsAString& aGroup,
nsGlobalChromeWindow* myself = static_cast<nsGlobalChromeWindow*>(this); nsGlobalChromeWindow* myself = static_cast<nsGlobalChromeWindow*>(this);
nsCOMPtr<nsIMessageBroadcaster> messageManager = nsCOMPtr<nsIMessageBroadcaster> messageManager =
myself->mGroupMessageManagers.Get(aGroup); myself->mGroupMessageManagers.LookupForAdd(aGroup).OrInsert(
[this, &aError] () {
if (!messageManager) { nsFrameMessageManager* parent =
nsFrameMessageManager* parent = static_cast<nsFrameMessageManager*>(GetMessageManager(aError));
static_cast<nsFrameMessageManager*>(GetMessageManager(aError));
messageManager = new nsFrameMessageManager(nullptr,
parent,
MM_CHROME | MM_BROADCASTER);
myself->mGroupMessageManagers.Put(aGroup, messageManager);
}
return new nsFrameMessageManager(nullptr,
parent,
MM_CHROME | MM_BROADCASTER);
});
return messageManager; return messageManager;
} }