Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help v8 hashing the bigint #14469

Merged
merged 1 commit into from Oct 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why using xor here?

}
return key;
};
Expand Down