8000 help v8 hashing the bigint · webpack/webpack@3fa83c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fa83c6

Browse files
committed
help v8 hashing the bigint
1 parent 2306d13 commit 3fa83c6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/optimize/SplitChunksPlugin.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,13 @@ module.exports = class SplitChunksPlugin {
774774
const chunkIndexMap = new Map();
775775
const ZERO = BigInt("0");
776776
const ONE = BigInt("1");
777-
let index = ONE;
777+
const START = ONE << BigInt("31");
778+
let index = START;
778779
for (const chunk of chunks) {
779-
chunkIndexMap.set(chunk, index);
780+
chunkIndexMap.set(
781+
chunk,
782+
index | BigInt((Math.random() * 0x7fffffff) | 0)
783+
);
780784
index = index << ONE;
781785
}
782786
/**
@@ -793,7 +797,8 @@ module.exports = class SplitChunksPlugin {
793797
let key =
794798
chunkIndexMap.get(first) | chunkIndexMap.get(result.value);
795799
while (!(result = iterator.next()).done) {
796-
key = key | chunkIndexMap.get(result.value);
800+
const raw = chunkIndexMap.get(result.value);
801+
key = key ^ raw;
797802
}
798803
return key;
799804
};

0 commit comments

Comments
 (0)
0