Skip to content

Commit

Permalink
Merge pull request #14469 from webpack/perf/hashing-bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 13, 2021
2 parents 2306d13 + 3fa83c6 commit 7e9534a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/optimize/SplitChunksPlugin.js
Expand Up @@ -774,9 +774,13 @@ module.exports = class SplitChunksPlugin {
const chunkIndexMap = new Map();
const ZERO = BigInt("0");
const ONE = BigInt("1");
let index = ONE;
const START = ONE << BigInt("31");
let index = START;
for (const chunk of chunks) {
chunkIndexMap.set(chunk, index);
chunkIndexMap.set(
chunk,
index | BigInt((Math.random() * 0x7fffffff) | 0)
);
index = index << ONE;
}
/**
Expand All @@ -793,7 +797,8 @@ module.exports = class SplitChunksPlugin {
let key =
chunkIndexMap.get(first) | chunkIndexMap.get(result.value);
while (!(result = iterator.next()).done) {
key = key | chunkIndexMap.get(result.value);
const raw = chunkIndexMap.get(result.value);
key = key ^ raw;
}
return key;
};
Expand Down

0 comments on commit 7e9534a

Please sign in to comment.