Skip to content

Commit 4f884f2

Browse files
authored
perf: avoid addComma on empty array
Just a small performance improvements when an array has only one item Signed-off-by: francesco <[email protected]>
1 parent 2b37f1d commit 4f884f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ function buildInnerObject (context, location) {
369369
code += 'let json = JSON_STR_BEGIN_OBJECT\n'
370370

371371
let addComma = ''
372-
if (!hasRequiredProperties) {
372+
if (!hasRequiredProperties && (propertiesKeys.length > 1 || (schema.patternProperties || schema.additionalProperties))) {
373373
code += 'let addComma = false\n'
374374
addComma = '!addComma && (addComma = true) || (json += JSON_STR_COMMA)'
375375
}

0 commit comments

Comments
 (0)