Skip to content

Commit

Permalink
Simplify identifier creation in ConcatenatedModules
Browse files Browse the repository at this point in the history
This was implemented in #5997 to fix some memory issues, but I think we
can make this a little more efficient. By using a single forEach instead
of a map, filter, and join, we avoid unnecessary array creations and
iterations.
  • Loading branch information
lencioni committed Nov 23, 2017
1 parent 7bbf31e commit 8fdf411
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -295,14 +295,12 @@ class ConcatenatedModule extends Module {
}

_createIdentifier() {
const orderedConcatenationListIdentifiers = this._orderedConcatenationList.map(info => {
switch(info.type) {
case "concatenated":
return info.module.identifier();
}
}).filter(Boolean).join(" ");
const hash = crypto.createHash("md5");
hash.update(orderedConcatenationListIdentifiers);
this._orderedConcatenationList.forEach(info => {
if(info.type === "concatenated") {
hash.update(info.module.identifier() + " ");
}
});
return this.rootModule.identifier() + " " + hash.digest("hex");
}

Expand Down

0 comments on commit 8fdf411

Please sign in to comment.