parallelize-async-work
ComputerGuy 2 weeks ago committed by GitHub
parent d4d82532ce
commit 229ab37134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -37,17 +37,16 @@ export function is_state_source(binding, analysis) {
* @returns {boolean}
*/
export function can_be_parallelized(expression, scope, analysis, bindings) {
let has_closures = false;
let should_stop = false;
/** @type {Set<string>} */
const references = new Set();
walk(/** @type {Node} */ (expression), null, {
ArrowFunctionExpression(_, { stop }) {
has_closures = true;
should_stop = true;
stop();
},
FunctionExpression(_, { stop }) {
has_closures = true;
should_stop = true;
stop();
},
Identifier(node, { path }) {
@ -68,11 +67,11 @@ export function can_be_parallelized(expression, scope, analysis, bindings) {
stop();
},
StaticBlock(node, { stop }) {
has_closures = true;
should_stop = true;
stop();
}
});
if (has_closures || should_stop) {
if (should_stop) {
return false;
}
for (const reference of references) {
@ -80,13 +79,14 @@ export function can_be_parallelized(expression, scope, analysis, bindings) {
if (!binding || binding.declaration_kind === 'import') {
return false;
}
if ('template' in analysis) {
if (binding.scope !== analysis.instance.scope) {
if (binding.scope !== analysis.module.scope) {
if (!('template' in analysis)) {
return false;
}
} else if (binding.scope !== analysis.module.scope) {
if (binding.scope !== analysis.instance.scope) {
return false;
}
}
if (bindings.includes(binding)) {
return false;

Loading…
Cancel
Save