]> git.codecow.com Git - nano25519.git/commitdiff
Capture array function instead of using patchable index accessor.
authorChris Duncan <chris@codecow.com>
Fri, 9 Oct 2026 21:03:37 +0000 (14:03 -0700)
committerChris Duncan <chris@codecow.com>
Fri, 9 Oct 2026 21:03:37 +0000 (14:03 -0700)
src/lib/primordials.ts
src/lib/verify.ts

index 7cf991d9b897958a3d086e35e390e95db379ff34..64c150893676ce3a5f2c3d43b21b6ef112ccd7e4 100644 (file)
@@ -84,6 +84,9 @@ export function allocate (length: number): Bytes {
        return new Bytes(length)
 }
 
+/** Captured version of `Array.push(value)`. */
+export const arrayPush = Function.prototype.call.bind(Array.prototype.push)
+
 /** Captured version of `Uint8Array.prototype.byteLength`. */
 export function byteLength (bytes: Uint8Array): number {
        return getByteLength(bytes)
index 20eccd45ac755d040b245b00527e787a8df85c70..c416de85694f19d541ba03403d5c19185301cd09 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
-import { allocate, byteLength, copy, isArray, normalize } from './primordials'
+import { allocate, byteLength, copy, isArray, normalize, arrayPush } from './primordials'
 import { Mutex, constants, getOutput, setInput, verify as wasm_verify, verify_blocks as wasm_verify_blocks, } from './wasm'
 
 const { BLOCKHASH_BYTELENGTH, KEY_BYTELENGTH, MAX_MESSAGE_BYTELENGTH, MAX_VERIFY_BLOCKS, SIGNATURE_BYTELENGTH, } = constants
@@ -58,7 +58,7 @@ export function verify_blocks (pub: unknown, data: unknown): boolean[] {
                setInput('msg', message)
                wasm_verify_blocks(count)
                for (let i = 0; i < count; i++) {
-                       verified[i] = getOutput('verify', i) === 1
+                       arrayPush(verified, getOutput('verify', i) === 1)
                }
                return verified
        } finally {