Skip to content

Commit 8fdf411

Browse files
committed
Simplify identifier creation in ConcatenatedModules
This was implemented in webpack#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.
1 parent 7bbf31e commit 8fdf411

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/optimize/ConcatenatedModule.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,12 @@ class ConcatenatedModule extends Module {
295295
}
296296

297297
_createIdentifier() {
298-
const orderedConcatenationListIdentifiers = this._orderedConcatenationList.map(info => {
299-
switch(info.type) {
300-
case "concatenated":
301-
return info.module.identifier();
302-
}
303-
}).filter(Boolean).join(" ");
304298
const hash = crypto.createHash("md5");
305-
hash.update(orderedConcatenationListIdentifiers);
299+
this._orderedConcatenationList.forEach(info => {
300+
if(info.type === "concatenated") {
301+
hash.update(info.module.identifier() + " ");
302+
}
303+
});
306304
return this.rootModule.identifier() + " " + hash.digest("hex");
307305
}
308306

0 commit comments

Comments
 (0)