Skip to content

Commit c494d11

Browse files
authored
Merge pull request #121 from immineal/perf-hash-worker-arraybuffer-18440103128429167746
⚡ Optimize ArrayBuffer mapping in Hash Generator Web Worker
2 parents 953da7f + 3faa0e4 commit c494d11

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tools/hash-generator/worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ self.onmessage = function (e) {
6767
function arrayBufferToWordArray(ab) {
6868
const u8 = new Uint8Array(ab);
6969
const len = u8.length;
70-
const words = [];
70+
const words = new Array(Math.ceil(len / 4));
7171
for (let i = 0; i < len; i += 4) {
72-
words.push(
72+
words[i >>> 2] = (
7373
(u8[i] << 24) |
7474
((u8[i + 1] || 0) << 16) |
7575
((u8[i + 2] || 0) << 8) |

0 commit comments

Comments
 (0)