[REF] compiler: minor cleanup

This commit merges two nested ifs and explicitly joins an array instead
of relying on array -> string coercion
This commit is contained in:
Samuel Degueldre
2023-08-04 08:49:08 +02:00
committed by Lucas Perais - lpe@odoo
parent 9823a4e7dd
commit 28672096a2
22 changed files with 99 additions and 101 deletions
+4 -6
View File
@@ -761,7 +761,7 @@ export class CodeGenerator {
if (!current) break;
}
}
this.addLine(`let ${block!.children.map((c) => c.varName)};`, codeIdx);
this.addLine(`let ${block!.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
}
return block!.varName;
@@ -863,7 +863,7 @@ export class CodeGenerator {
if (!current) break;
}
}
this.addLine(`let ${block!.children.map((c) => c.varName)};`, codeIdx);
this.addLine(`let ${block!.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
// note: this part is duplicated from end of compilemulti:
@@ -998,8 +998,7 @@ export class CodeGenerator {
}
}
if (isNewBlock) {
if (block!.hasDynamicChildren) {
if (block!.children.length) {
if (block!.hasDynamicChildren && block!.children.length) {
const code = this.target.code;
const children = block!.children.slice();
let current = children.shift();
@@ -1010,8 +1009,7 @@ export class CodeGenerator {
if (!current) break;
}
}
this.addLine(`let ${block!.children.map((c) => c.varName)};`, codeIdx);
}
this.addLine(`let ${block!.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
const args = block!.children.map((c) => c.varName).join(", ");