зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1693541 - Improve uses of nsBaseHashtable and descendants and avoid multiple subsequent lookups in dom/base. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D106105
This commit is contained in:
Родитель
165b32796c
Коммит
ee037ba882
|
@ -812,22 +812,27 @@ Document* ExternalResourceMap::RequestResource(
|
|||
return resource->mDocument;
|
||||
}
|
||||
|
||||
RefPtr<PendingLoad>& loadEntry = mPendingLoads.LookupOrInsert(clone);
|
||||
if (loadEntry) {
|
||||
RefPtr<PendingLoad> load(loadEntry);
|
||||
load.forget(aPendingLoad);
|
||||
return nullptr;
|
||||
}
|
||||
bool loadStartSucceeded =
|
||||
mPendingLoads.WithEntryHandle(clone, [&](auto&& loadEntry) {
|
||||
if (!loadEntry) {
|
||||
loadEntry.Insert(MakeRefPtr<PendingLoad>(aDisplayDocument));
|
||||
|
||||
RefPtr<PendingLoad> load(new PendingLoad(aDisplayDocument));
|
||||
loadEntry = load;
|
||||
if (NS_FAILED(loadEntry.Data()->StartLoad(clone, aReferrerInfo,
|
||||
aRequestingNode))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(load->StartLoad(clone, aReferrerInfo, aRequestingNode))) {
|
||||
RefPtr<PendingLoad> load(loadEntry.Data());
|
||||
load.forget(aPendingLoad);
|
||||
return true;
|
||||
});
|
||||
if (!loadStartSucceeded) {
|
||||
// Make sure we don't thrash things by trying this load again, since
|
||||
// chances are it failed for good reasons (security check, etc).
|
||||
// This must be done outside the WithEntryHandle functor, as it accesses
|
||||
// mPendingLoads.
|
||||
AddExternalResource(clone, nullptr, nullptr, aDisplayDocument);
|
||||
} else {
|
||||
load.forget(aPendingLoad);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
|
@ -235,10 +235,12 @@ TMimeType<char_type>::Parse(const nsTSubstring<char_type>& aMimeType) {
|
|||
|
||||
// Step 11.10
|
||||
if (!paramName.IsEmpty() && !paramNameHadInvalidChars &&
|
||||
!paramValueHadInvalidChars &&
|
||||
!mimeType->mParameters.Get(paramName, ¶mValue)) {
|
||||
mimeType->mParameters.InsertOrUpdate(paramName, paramValue);
|
||||
mimeType->mParameterNames.AppendElement(paramName);
|
||||
!paramValueHadInvalidChars) {
|
||||
// XXX Is the assigned value used anywhere?
|
||||
paramValue = mimeType->mParameters.LookupOrInsertWith(paramName, [&] {
|
||||
mimeType->mParameterNames.AppendElement(paramName);
|
||||
return paramValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,12 +311,14 @@ template <typename char_type>
|
|||
void TMimeType<char_type>::SetParameterValue(
|
||||
const nsTSubstring<char_type>& aName,
|
||||
const nsTSubstring<char_type>& aValue) {
|
||||
if (!mParameters.Get(aName, nullptr)) {
|
||||
mParameterNames.AppendElement(aName);
|
||||
}
|
||||
ParameterValue value;
|
||||
value.Append(aValue);
|
||||
mParameters.InsertOrUpdate(aName, value);
|
||||
mParameters.WithEntryHandle(aName, [&](auto&& entry) {
|
||||
if (!entry) {
|
||||
mParameterNames.AppendElement(aName);
|
||||
}
|
||||
ParameterValue value;
|
||||
value.Append(aValue);
|
||||
entry.InsertOrUpdate(std::move(value));
|
||||
});
|
||||
}
|
||||
|
||||
template mozilla::UniquePtr<TMimeType<char16_t>> TMimeType<char16_t>::Parse(
|
||||
|
|
|
@ -964,7 +964,7 @@ bool nsContentUtils::InitializeEventTable() {
|
|||
|
||||
// Subtract one from the length because of the trailing null
|
||||
for (uint32_t i = 0; i < ArrayLength(eventArray) - 1; ++i) {
|
||||
MOZ_ASSERT(!sAtomEventTable->Lookup(eventArray[i].mAtom),
|
||||
MOZ_ASSERT(!sAtomEventTable->Contains(eventArray[i].mAtom),
|
||||
"Double-defining event name; fix your EventNameList.h");
|
||||
sAtomEventTable->InsertOrUpdate(eventArray[i].mAtom, eventArray[i]);
|
||||
if (ShouldAddEventToStringEventTable(eventArray[i])) {
|
||||
|
|
|
@ -1005,9 +1005,9 @@ void MessageManagerReporter::CountReferents(
|
|||
}
|
||||
|
||||
nsString key(it.Key());
|
||||
const uint32_t oldCount = aReferentCount->mMessageCounter.Get(key);
|
||||
uint32_t currentCount = oldCount + listenerCount;
|
||||
aReferentCount->mMessageCounter.InsertOrUpdate(key, currentCount);
|
||||
const uint32_t currentCount =
|
||||
(aReferentCount->mMessageCounter.LookupOrInsert(key, 0) +=
|
||||
listenerCount);
|
||||
|
||||
// Keep track of messages that have a suspiciously large
|
||||
// number of referents (symptom of leak).
|
||||
|
|
|
@ -1007,7 +1007,7 @@ nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow,
|
|||
|
||||
// Add ourselves to the inner windows list.
|
||||
MOZ_ASSERT(sInnerWindowsById, "Inner Windows hash table must be created!");
|
||||
MOZ_ASSERT(!sInnerWindowsById->Get(mWindowID),
|
||||
MOZ_ASSERT(!sInnerWindowsById->Contains(mWindowID),
|
||||
"This window shouldn't be in the hash table yet!");
|
||||
// We seem to see crashes in release builds because of null
|
||||
// |sInnerWindowsById|.
|
||||
|
|
|
@ -1371,7 +1371,7 @@ nsGlobalWindowOuter::nsGlobalWindowOuter(uint64_t aWindowID)
|
|||
MOZ_ASSERT(sOuterWindowsById, "Outer Windows hash table must be created!");
|
||||
|
||||
// |this| is an outer window, add to the outer windows list.
|
||||
MOZ_ASSERT(!sOuterWindowsById->Get(mWindowID),
|
||||
MOZ_ASSERT(!sOuterWindowsById->Contains(mWindowID),
|
||||
"This window shouldn't be in the hash table yet!");
|
||||
// We seem to see crashes in release builds because of null
|
||||
// |sOuterWindowsById|.
|
||||
|
|
Загрузка…
Ссылка в новой задаче