Skip to content

Commit 3e9d65e

Browse files
refactor(graph): create an owned export info in one place
`getOwnExportInfo` and `getExportInfo` each built the export info and allocated the map for the first one. Only the second is reached from `lib/`, so the first one's allocation was never exercised; both now go through one helper.
1 parent 5f9e60a commit 3e9d65e

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎lib/graph/ExportsInfo.js‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,16 @@ class ExportsInfo {
425425
getOwnExportInfo(name) {
426426
const info = this._exports.get(name);
427427
if (info !== undefined) return info;
428+
return this._createOwnExportInfo(name);
429+
}
430+
431+
/**
432+
* Adds an export info this exportsInfo owns, allocating its map for the first.
433+
* @param {ExportInfoName} name export name
434+
* @returns {ExportInfo} the new export info
435+
* @private
436+
*/
437+
_createOwnExportInfo(name) {
428438
const newInfo = new ExportInfo(name, this._otherExportsInfo);
429439
if (this._exports === NO_OWN_EXPORTS) this._exports = new Map();
430440
this._exports.set(name, newInfo);
@@ -443,11 +453,7 @@ class ExportsInfo {
443453
if (this._redirectTo !== undefined) {
444454
return this._redirectTo.getExportInfo(name);
445455
}
446-
const newInfo = new ExportInfo(name, this._otherExportsInfo);
447-
if (this._exports === NO_OWN_EXPORTS) this._exports = new Map();
448-
this._exports.set(name, newInfo);
449-
this._exportsAreOrdered = false;
450-
return newInfo;
456+
return this._createOwnExportInfo(name);
451457
}
452458

453459
/**

0 commit comments

Comments
 (0)