]> git.codecow.com Git - nano25519.git/commitdiff
Reduce load calls and eliminate loop in blake-gen.
authorChris Duncan <chris@codecow.com>
Tue, 29 Sep 2026 19:57:51 +0000 (12:57 -0700)
committerChris Duncan <chris@codecow.com>
Tue, 29 Sep 2026 19:57:51 +0000 (12:57 -0700)
scripts/blake2b-gen.mjs

index 815c55515adc0e879f8748173f824e95e0691dc4..7d189fb6b1b136cfb7da98c233531f7c83869cea 100644 (file)
@@ -110,17 +110,15 @@ const INIT = (() => {
 
        output += `
                // initialize hash state
+               const p_ptr = changetype<usize>(this.p)
        `
        for (let i = 0; i < H_LENGTH; i++) {
                output += `
-                       this.h[${i}] = ${blake2b_iv[i]}
+                       this.h[${i}] = ${blake2b_iv[i]} ^ load<u64>(p_ptr, ${i << 3})
                `
        }
 
        output += `
-               for (let i = 0; i < ${H_LENGTH}; i++) {
-                       this.h[i] ^= load<u64>(changetype<usize>(this.p) + (i << 3))
-               }
                return this
        }
        `