From e2697f11d10eb12ef288a39745cb2c1185c91255 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 9 Oct 2026 14:03:37 -0700 Subject: [PATCH] Capture array function instead of using patchable index accessor. --- src/lib/primordials.ts | 3 +++ src/lib/verify.ts | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/primordials.ts b/src/lib/primordials.ts index 7cf991d..64c1508 100644 --- a/src/lib/primordials.ts +++ b/src/lib/primordials.ts @@ -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) diff --git a/src/lib/verify.ts b/src/lib/verify.ts index 20eccd4..c416de8 100644 --- a/src/lib/verify.ts +++ b/src/lib/verify.ts @@ -1,7 +1,7 @@ //! SPDX-FileCopyrightText: 2026 Chris Duncan //! 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 { -- 2.52.0