Skip to content

Commit

Permalink
refactor(language-core): use yield* instead of for..of + yield
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Feb 25, 2025
1 parent 130e3b8 commit c95ae1f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions packages/language-core/lib/codegen/script/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export function* generateComponent(
yield `},${newLine}`;
if (!ctx.bypassDefineComponent) {
const emitOptionCodes = [...generateEmitsOption(options, scriptSetupRanges)];
for (const code of emitOptionCodes) {
yield code;
}
yield* emitOptionCodes;
yield* generatePropsOption(options, ctx, scriptSetup, scriptSetupRanges, !!emitOptionCodes.length, true);
}
if (
Expand Down
4 changes: 1 addition & 3 deletions packages/language-core/lib/codegen/script/componentSelf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ export function* generateComponentSelf(
yield `},${newLine}`; // setup() {
if (options.sfc.scriptSetup && options.scriptSetupRanges && !ctx.bypassDefineComponent) {
const emitOptionCodes = [...generateEmitsOption(options, options.scriptSetupRanges)];
for (const code of emitOptionCodes) {
yield code;
}
yield* emitOptionCodes;
yield* generatePropsOption(options, ctx, options.sfc.scriptSetup, options.scriptSetupRanges, !!emitOptionCodes.length, false);
}
if (options.sfc.script && options.scriptRanges?.exportDefault?.args) {
Expand Down
4 changes: 1 addition & 3 deletions packages/language-core/lib/codegen/script/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ function* generateTemplateBody(
yield* generateCssVars(options, templateCodegenCtx);

if (options.templateCodegen) {
for (const code of options.templateCodegen.codes) {
yield code;
}
yield* options.templateCodegen.codes;
}
else {
yield `// no template${newLine}`;
Expand Down
4 changes: 1 addition & 3 deletions packages/language-core/lib/codegen/template/vIf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export function* generateVIf(
`)`
),
];
for (const code of codes) {
yield code;
}
yield* codes;
ctx.blockConditions.push(toString(codes));
addedBlockCondition = true;
yield ` `;
Expand Down

0 comments on commit c95ae1f

Please sign in to comment.