Skip to content

Commit 00549ff

Browse files
authored
perf: iterate children using a for loop (#694)
1 parent 73479f9 commit 00549ff

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/parser/converts/block.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,17 @@ export function convertIfBlock(
147147
});
148148
const consequent = getConsequentFromIfBlock(node);
149149

150-
ifBlock.children.push(
151-
...convertChildren(
152-
{
153-
nodes:
154-
// Adjust for Svelte v5
155-
trimChildren(getChildren(consequent)),
156-
},
157-
ifBlock,
158-
ctx,
159-
),
160-
);
150+
for (const child of convertChildren(
151+
{
152+
nodes:
153+
// Adjust for Svelte v5
154+
trimChildren(getChildren(consequent)),
155+
},
156+
ifBlock,
157+
ctx,
158+
)) {
159+
ifBlock.children.push(child);
160+
}
161161

162162
ctx.scriptLet.closeScope();
163163
if (elseif) {
@@ -218,17 +218,17 @@ export function convertIfBlock(
218218
ifBlock.else = elseBlock;
219219

220220
ctx.scriptLet.nestBlock(elseBlock);
221-
elseBlock.children.push(
222-
...convertChildren(
223-
{
224-
nodes:
225-
// Adjust for Svelte v5
226-
trimChildren(elseChildren),
227-
},
228-
elseBlock,
229-
ctx,
230-
),
231-
);
221+
for (const child of convertChildren(
222+
{
223+
nodes:
224+
// Adjust for Svelte v5
225+
trimChildren(elseChildren),
226+
},
227+
elseBlock,
228+
ctx,
229+
)) {
230+
elseBlock.children.push(child);
231+
}
232232
ctx.scriptLet.closeScope();
233233
extractMustacheBlockTokens(elseBlock, ctx, { startOnly: true });
234234

0 commit comments

Comments
 (0)