Skip to content

Commit

Permalink
perf: switch from object spread to Object.assign when merging globa…
Browse files Browse the repository at this point in the history
…ls (#16311)

Refs #16302
  • Loading branch information
mdjermanovic committed Sep 16, 2022
1 parent 1729f9e commit 504fe59
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/linter/linter.js
Expand Up @@ -1601,12 +1601,18 @@ class Linter {
languageOptions.ecmaVersion
);

// add configured globals and language globals
const configuredGlobals = {
...(getGlobalsForEcmaVersion(languageOptions.ecmaVersion)),
...(languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0),
...languageOptions.globals
};
/*
* add configured globals and language globals
*
* using Object.assign instead of object spread for performance reasons
* https://github.com/eslint/eslint/issues/16302
*/
const configuredGlobals = Object.assign(
{},
getGlobalsForEcmaVersion(languageOptions.ecmaVersion),
languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0,
languageOptions.globals
);

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

0 comments on commit 504fe59

Please sign in to comment.