@samitouri / QOS-React / commits / 5d81fdeb5f

[easy] use yield* in eachInstructionOperand

Noticed we could simplify this code a bit using `yield*`.

Jan Kassens committed Nov 7, 2022 at 15:10 UTC 5d81fdeb5f1ae606d34d7a5b594a21c293912159
1 file changed +6 -19
compiler/forget/src/HIR/HIRBuilder.ts
+6 -19
@@ -626,9 +626,7 @@ export function* eachInstructionOperand(instr: Instruction) {
626 case "NewExpression":
627 case "CallExpression": {
628 yield instrValue.callee;
629 - for (const arg of instrValue.args) {
630 - yield arg;
631 - }
629 + yield* instrValue.args;
630 break;
631 }
632 case "BinaryExpression": {
@@ -646,35 +644,24 @@ export function* eachInstructionOperand(instr: Instruction) {
644 }
645 case "JsxExpression": {
646 yield instrValue.tag;
649 - for (const place of instrValue.props.values()) {
650 - yield place;
651 - }
647 + yield* instrValue.props.values();
648 if (instrValue.children) {
653 - for (const c of instrValue.children) {
654 - yield c;
655 - }
649 + yield* instrValue.children;
650 }
651 break;
652 }
653 case "JsxFragment": {
660 - for (const c of instrValue.children) {
661 - yield c;
662 - }
654 + yield* instrValue.children;
655 break;
656 }
657 case "ObjectExpression": {
658 if (instrValue.properties !== null) {
667 - const props = instrValue.properties;
668 - for (const place of props.values()) {
669 - yield place;
670 - }
659 + yield* instrValue.properties.values();
660 }
661 break;
662 }
663 case "ArrayExpression": {
675 - for (const e of instrValue.elements) {
676 - yield e;
677 - }
664 + yield* instrValue.elements;
665 break;
666 }
667 case "OtherStatement":