improve performance of getModuleRuntimes

This commit is contained in:
Tobias Koppers 2021-02-23 00:25:38 +01:00
parent 63c14ccbfc
commit 84ec7708c2
1 changed files with 13 additions and 5 deletions

View File

@ -69,6 +69,18 @@ const getArray = set => {
return Array.from(set); return Array.from(set);
}; };
/**
* @param {SortableSet<Chunk>} chunks the chunks
* @returns {RuntimeSpecSet} runtimes
*/
const getModuleRuntimes = chunks => {
const runtimes = new RuntimeSpecSet();
for (const chunk of chunks) {
runtimes.add(chunk.runtime);
}
return runtimes;
};
/** /**
* @param {SortableSet<Module>} set the set * @param {SortableSet<Module>} set the set
* @returns {Map<string, SortableSet<Module>>} modules by source type * @returns {Map<string, SortableSet<Module>>} modules by source type
@ -510,11 +522,7 @@ class ChunkGraph {
*/ */
getModuleRuntimes(module) { getModuleRuntimes(module) {
const cgm = this._getChunkGraphModule(module); const cgm = this._getChunkGraphModule(module);
const runtimes = new RuntimeSpecSet(); return cgm.chunks.getFromUnorderedCache(getModuleRuntimes);
for (const chunk of cgm.chunks) {
runtimes.add(chunk.runtime);
}
return runtimes;
} }
/** /**