From 67c2b502dda8b651aa5cbf6c85755a844492ec79 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 8 Nov 2019 12:22:00 +0100 Subject: [PATCH] allocate ModuleGraphConnections.explanations only when needed --- lib/ModuleGraphConnection.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ModuleGraphConnection.js b/lib/ModuleGraphConnection.js index 15f34d852..97f0ba0e2 100644 --- a/lib/ModuleGraphConnection.js +++ b/lib/ModuleGraphConnection.js @@ -36,8 +36,9 @@ class ModuleGraphConnection { /** @type {function(): boolean} */ this.condition = condition; /** @type {Set} */ - this.explanations = new Set(); + this.explanations = undefined; if (explanation) { + this.explanations = new Set(); this.explanations.add(explanation); } } @@ -61,10 +62,14 @@ class ModuleGraphConnection { * @returns {void} */ addExplanation(explanation) { + if (this.explanations === undefined) { + this.explanations = new Set(); + } this.explanations.add(explanation); } get explanation() { + if (this.explanations === undefined) return ""; return Array.from(this.explanations).join(" "); }