remove unused

parallelize-async-work
ComputerGuy 6 days ago
parent c8cc9319be
commit 464d7b6eab

@ -97,7 +97,6 @@ export interface ParallelizedChunk {
/** index in instance body */ /** index in instance body */
position: number; position: number;
bindings: Binding[]; bindings: Binding[];
type: 'promise_all' | 'all';
} }
export type Context = import('zimmerframe').Context<AST.SvelteNode, ClientTransformState>; export type Context = import('zimmerframe').Context<AST.SvelteNode, ClientTransformState>;

@ -152,17 +152,12 @@ export function Program(node, context) {
chunk.position + offset, chunk.position + offset,
0, 0,
b.declaration(chunk.kind, [ b.declaration(chunk.kind, [
b.declarator( b.declarator(declarator.id, b.call(b.await(b.call('$.save', declarator.init))))
declarator.id,
chunk.type === 'promise_all'
? b.await(declarator.init)
: b.call(b.await(b.call('$.save', declarator.init)))
)
]) ])
); );
} else { } else {
const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id)); const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id));
const init = b.call(`$.${chunk.type}`, ...chunk.declarators.map(({ init }) => init)); const init = b.call(`$.all`, ...chunk.declarators.map(({ init }) => init));
body.splice( body.splice(
chunk.position + offset, chunk.position + offset,
0, 0,

@ -71,8 +71,7 @@ export function VariableDeclaration(node, context) {
]; ];
if ( if (
context.state.current_parallelized_chunk && context.state.current_parallelized_chunk &&
context.state.current_parallelized_chunk.kind === node.kind && context.state.current_parallelized_chunk.kind === node.kind
context.state.current_parallelized_chunk.type === 'all'
) { ) {
context.state.current_parallelized_chunk.declarators.push(...declarators); context.state.current_parallelized_chunk.declarators.push(...declarators);
context.state.current_parallelized_chunk.bindings.push(...bindings); context.state.current_parallelized_chunk.bindings.push(...bindings);
@ -85,8 +84,7 @@ export function VariableDeclaration(node, context) {
kind: node.kind, kind: node.kind,
declarators, declarators,
position: /** @type {Program} */ (context.path.at(-1)).body.indexOf(node), position: /** @type {Program} */ (context.path.at(-1)).body.indexOf(node),
bindings, bindings
type: 'all'
}; };
context.state.current_parallelized_chunk = chunk; context.state.current_parallelized_chunk = chunk;
context.state.parallelized_chunks.push(chunk); context.state.parallelized_chunks.push(chunk);
@ -268,8 +266,6 @@ export function VariableDeclaration(node, context) {
...context.state.scope.get_bindings(declarator) ...context.state.scope.get_bindings(declarator)
]); ]);
} }
// const type = parallelize ? (dev ? 'promise_all' : 'all') : null;
const type = 'all';
/** @type {VariableDeclarator[]} */ /** @type {VariableDeclarator[]} */
const derived_declarators = []; const derived_declarators = [];
@ -383,8 +379,7 @@ export function VariableDeclaration(node, context) {
})); }));
if ( if (
context.state.current_parallelized_chunk && context.state.current_parallelized_chunk &&
context.state.current_parallelized_chunk.kind === node.kind && context.state.current_parallelized_chunk.kind === node.kind
context.state.current_parallelized_chunk.type === type
) { ) {
context.state.current_parallelized_chunk.declarators.push(...declarators); context.state.current_parallelized_chunk.declarators.push(...declarators);
context.state.current_parallelized_chunk.bindings.push(...bindings); context.state.current_parallelized_chunk.bindings.push(...bindings);
@ -397,8 +392,7 @@ export function VariableDeclaration(node, context) {
kind: node.kind, kind: node.kind,
declarators, declarators,
position: /** @type {Program} */ (context.path.at(-1)).body.indexOf(node), position: /** @type {Program} */ (context.path.at(-1)).body.indexOf(node),
bindings, bindings
type: /** @type {ParallelizedChunk['type']} */ (type)
}; };
context.state.current_parallelized_chunk = chunk; context.state.current_parallelized_chunk = chunk;
context.state.parallelized_chunks.push(chunk); context.state.parallelized_chunks.push(chunk);

@ -102,7 +102,6 @@ export {
all, all,
async_body, async_body,
for_await_track_reactivity_loss, for_await_track_reactivity_loss,
promise_all,
save, save,
track_reactivity_loss track_reactivity_loss
} from './reactivity/async.js'; } from './reactivity/async.js';

@ -202,5 +202,3 @@ export function all(...promises) {
) )
); );
} }
export const promise_all = Promise.all;

Loading…
Cancel
Save