From 5990e8374cfe58fe202880a48adf5853f206f28f Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 5 Jan 2025 01:24:15 -0800 Subject: [PATCH] Shortcut conditional by validating nonce prior to loading atomic. Remove redundant return statement. --- src/lib/workers/powgpu.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/workers/powgpu.ts b/src/lib/workers/powgpu.ts index 431f1eb..707fcab 100644 --- a/src/lib/workers/powgpu.ts +++ b/src/lib/workers/powgpu.ts @@ -214,11 +214,10 @@ export class PowGpu extends WorkerInterface { /** * Set nonce if it passes the threshold and no other thread has set it */ - if (atomicLoad(&work.found) == 0u && (BLAKE2B_IV32_1 ^ v[1u] ^ v[17u]) > ubo.threshold) { + if (BLAKE2B_IV32_1 ^ v[1u] ^ v[17u]) > ubo.threshold && atomicStore(&work.found) == 0u) { atomicStore(&work.found, 1u); work.nonce.x = m[0]; work.nonce.y = m[1]; - return; } return; } -- 2.34.1