Skip to content

Commit 504fe59

Browse files
authored
perf: switch from object spread to Object.assign when merging globals (#16311)
Refs #16302
1 parent 1729f9e commit 504fe59

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

lib/linter/linter.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,12 +1601,18 @@ class Linter {
16011601
languageOptions.ecmaVersion
16021602
);
16031603

1604-
// add configured globals and language globals
1605-
const configuredGlobals = {
1606-
...(getGlobalsForEcmaVersion(languageOptions.ecmaVersion)),
1607-
...(languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0),
1608-
...languageOptions.globals
1609-
};
1604+
/*
1605+
* add configured globals and language globals
1606+
*
1607+
* using Object.assign instead of object spread for performance reasons
1608+
* https://github.com/eslint/eslint/issues/16302
1609+
*/
1610+
const configuredGlobals = Object.assign(
1611+
{},
1612+
getGlobalsForEcmaVersion(languageOptions.ecmaVersion),
1613+
languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0,
1614+
languageOptions.globals
1615+
);
16101616

16111617
// double check that there is a parser to avoid mysterious error messages
16121618
if (!languageOptions.parser) {

0 commit comments

Comments
 (0)