parallelize-async-work
ComputerGuy 5 days ago committed by GitHub
parent e07672b9f9
commit a5a5b8da89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -37,6 +37,7 @@ export function is_state_source(binding, analysis) {
*/
export function can_be_parallelized(expression, scope, analysis) {
let has_closures = false;
let should_stop = false;
/** @type {Set<string>} */
const references = new Set();
walk(expression, null, {
@ -52,9 +53,21 @@ export function can_be_parallelized(expression, scope, analysis) {
if (is_reference(node, /** @type {Node} */ (path.at(-1)))) {
references.add(node.name);
}
},
MemberExpression(node, { stop }) {
should_stop = true;
stop();
},
CallExpression(node, { stop }) {
should_stop = true;
stop();
},
NewExpression(node, { stop }) {
should_stop = true;
stop();
}
});
if (has_closures) {
if (has_closures || should_stop) {
return false;
}
for (const reference of references) {

Loading…
Cancel
Save