Bug 1372013 - Remove a redundant mFetchingModules.Get before Remove call, and replace Get+Put calls with a LookupRemoveIf call. r=froydnj

MozReview-Commit-ID: LDQkiin1hgf
This commit is contained in:
Mats Palmgren 2017-06-14 16:11:21 +02:00
Родитель 0b07470173
Коммит fb22ab5655
1 изменённых файлов: 11 добавлений и 7 удалений

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

@ -311,8 +311,7 @@ ScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest*
MOZ_ASSERT(!aRequest->IsReadyToRun()); MOZ_ASSERT(!aRequest->IsReadyToRun());
RefPtr<GenericPromise::Private> promise; RefPtr<GenericPromise::Private> promise;
MOZ_ALWAYS_TRUE(mFetchingModules.Get(aRequest->mURI, getter_AddRefs(promise))); MOZ_ALWAYS_TRUE(mFetchingModules.Remove(aRequest->mURI, getter_AddRefs(promise)));
mFetchingModules.Remove(aRequest->mURI);
RefPtr<ModuleScript> ms(aRequest->mModuleScript); RefPtr<ModuleScript> ms(aRequest->mModuleScript);
MOZ_ASSERT(NS_SUCCEEDED(aResult) == (ms != nullptr)); MOZ_ASSERT(NS_SUCCEEDED(aResult) == (ms != nullptr));
@ -333,11 +332,16 @@ ScriptLoader::WaitForModuleFetch(ModuleLoadRequest* aRequest)
MOZ_ASSERT(ModuleMapContainsModule(aRequest)); MOZ_ASSERT(ModuleMapContainsModule(aRequest));
RefPtr<GenericPromise::Private> promise; RefPtr<GenericPromise::Private> promise;
if (mFetchingModules.Get(aRequest->mURI, getter_AddRefs(promise))) { mFetchingModules.LookupRemoveIf(aRequest->mURI,
if (!promise) { [&promise] (RefPtr<GenericPromise::Private>& aValue) {
promise = new GenericPromise::Private(__func__); if (!aValue) {
mFetchingModules.Put(aRequest->mURI, promise); aValue = new GenericPromise::Private(__func__);
} }
promise = aValue;
return false; // don't remove the entry
});
if (promise) {
return promise; return promise;
} }