From 504fe59b0e0f4f5a2afb6a69aaed5cb4ca631012 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Sat, 17 Sep 2022 00:12:11 +0200 Subject: [PATCH] perf: switch from object spread to `Object.assign` when merging globals (#16311) Refs #16302 --- lib/linter/linter.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/linter/linter.js b/lib/linter/linter.js index a29ce923792..16059623472 100644 --- a/lib/linter/linter.js +++ b/lib/linter/linter.js @@ -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) {