allocate ModuleGraphConnections.explanations only when needed

This commit is contained in:
Tobias Koppers 2019-11-08 12:22:00 +01:00
parent efe0c2e610
commit 67c2b502dd
1 changed files with 6 additions and 1 deletions

View File

@ -36,8 +36,9 @@ class ModuleGraphConnection {
/** @type {function(): boolean} */
this.condition = condition;
/** @type {Set<string>} */
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(" ");
}