mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-17 12:56:09 +00:00
perf(packages/codegen): reduce branches in printArguments (#27607)
Small perf optimization. The loop always checks if `length === 0` anyway before first iteration, so there's no real gain in checking it manually.
This commit is contained in:
1 parent
262dd21150
commit
adc90edea0
1 file changed
+1
-7
@@ -407,15 +407,9 @@ function printArguments(
|
||||
args: ESTree.Argument[],
|
||||
state: State,
|
||||
): void {
|
||||
const { length } = args;
|
||||
if (length === 0) {
|
||||
writeNoLast(state, "(");
|
||||
writeWithMapEnd(state, ")", CAT_CLOSE_BRACKET, node.start, node.end, node);
|
||||
return;
|
||||
}
|
||||
|
||||
write(state, "(", CAT_OTHER);
|
||||
|
||||
const { length } = args;
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (i > 0) write(state, ", ", CAT_OTHER);
|
||||
|
||||
|
||||
Reference in new issue
Block a user