]> zoso.dev Git - nano-pow.git/commitdiff
Replace another if statement with select.
authorChris Duncan <chris@zoso.dev>
Wed, 5 Feb 2025 13:40:14 +0000 (05:40 -0800)
committerChris Duncan <chris@zoso.dev>
Wed, 5 Feb 2025 13:40:14 +0000 (05:40 -0800)
src/shaders/compute.wgsl

index 9c5cf9ca89a0ac384d4e658bf61fe921001cc32f..0ea306e1c3d55953774087d208018ad96016c77e 100644 (file)
@@ -1456,9 +1456,6 @@ fn main(id: vec3<u32>) {
        * Set nonce if it passes the threshold and no other thread has set it.
        * Only high bits are needed for comparison since threshold low bits are zero.
        */
-       if ((BLAKE2B_IV_0.y ^ v0.y ^ v8.y) >= ubo.threshold) {
-               let wasFound: u32 = atomicExchange(&work.found, 1u);
-               work.nonce = select(work.nonce, m0, wasFound == 0u);
-       }
+       work.nonce = select(work.nonce, m0, (BLAKE2B_IV_0.y ^ v0.y ^ v8.y) >= ubo.threshold && atomicExchange(&work.found, 1u) == 0u);
        return;
 }