Skip to content

Commit

Permalink
don't reprocess entry point if previously processed with same loaded …
Browse files Browse the repository at this point in the history
…modules

if there are now more loaded modules than before there's no point processing, given not painting the loaded modules would have no effect given they were already painted in the previous run
  • Loading branch information
tjenkinson committed Jan 26, 2020
1 parent ddd643d commit a0ed839
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/chunkColouring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ function randomColour(): Uint8Array {
return randomUint8Array(10);
}

function setsEqual<T>(a: Set<T>, b: Set<T>): boolean {
return a.size === b.size && [...a].every(item => b.has(item));
function subset<T>(small: Set<T>, big: Set<T>): boolean {
return small.size <= big.size && [...small].every(item => big.has(item));
}

interface StaticModuleGroup {
Expand Down Expand Up @@ -69,10 +69,10 @@ export function assignChunkColouringHashes(
loadedModules: Set<Module>,
paint: Uint8Array
): void {
const alreadySeen = entryModules.some(
entry => entry.rootModule === rootModule && setsEqual(entry.loadedModules, loadedModules)
const alreadyProcessed = entryModules.some(
entry => entry.rootModule === rootModule && subset(entry.loadedModules, loadedModules)
);
if (!alreadySeen) {
if (!alreadyProcessed) {
entryModules.push({
loadedModules,
paint,
Expand Down

0 comments on commit a0ed839

Please sign in to comment.