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);
nsCOMPtr<nsIMessageBroadcaster> messageManager =
myself->mGroupMessageManagers.Get(aGroup);
if (!messageManager) {
nsFrameMessageManager* parent =
static_cast<nsFrameMessageManager*>(GetMessageManager(aError));
messageManager = new nsFrameMessageManager(nullptr,
parent,
MM_CHROME | MM_BROADCASTER);
myself->mGroupMessageManagers.Put(aGroup, messageManager);
}
myself->mGroupMessageManagers.LookupForAdd(aGroup).OrInsert(
[this, &aError] () {
nsFrameMessageManager* parent =
static_cast<nsFrameMessageManager*>(GetMessageManager(aError));
return new nsFrameMessageManager(nullptr,
parent,
MM_CHROME | MM_BROADCASTER);
});
return messageManager;
}