Bug 1766276 - Give MaybeOneOf a map method r=jandem
There are a few places where we call one of two overloads of a fuction based on the contents of a MaybeOneOf. We can simplify this code by giving the class a map method. Differential Revision: https://phabricator.services.mozilla.com/D144595
This commit is contained in:
@@ -187,11 +187,10 @@ nsresult ModuleLoader::CompileOrFinishModuleScript(
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
stencil = maybeSource.constructed<SourceText<char16_t>>()
|
||||
? JS::CompileModuleScriptToStencil(
|
||||
aCx, aOptions, maybeSource.ref<SourceText<char16_t>>())
|
||||
: JS::CompileModuleScriptToStencil(
|
||||
aCx, aOptions, maybeSource.ref<SourceText<Utf8Unit>>());
|
||||
auto compile = [&](auto& source) {
|
||||
return JS::CompileModuleScriptToStencil(aCx, aOptions, source);
|
||||
};
|
||||
stencil = maybeSource.mapNonEmpty(compile);
|
||||
} else {
|
||||
MOZ_ASSERT(aRequest->IsBytecode());
|
||||
JS::DecodeOptions decodeOptions(aOptions);
|
||||
|
||||
Reference in New Issue
Block a user