mymarkdown

My markdown
git clone https://git.grace.moe/mymarkdown
Log | Files | Refs

commit 568cd19766617323594a89b4710f8ffba32bc98c
parent bd0bdd9c77b55e65f23535c3530a88cd83a6edae
Author: gracefu <81774659+gracefuu@users.noreply.github.com>
Date:   Wed, 21 May 2025 13:49:53 +0800

Simplify simd indexOf* slightly

Diffstat:
Msrc/padded_str_impl.zig | 18++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/padded_str_impl.zig b/src/padded_str_impl.zig @@ -205,13 +205,8 @@ pub fn PaddedMany(comptime PADDING_: usize) type { for (splats) |splat| { unmatches_bits &= @bitCast(block != splat); } - const unmatches_bools: simd.BoolBlock = @bitCast(unmatches_bits); - if (@reduce(.Or, unmatches_bools)) { - const unmatches_int: simd.IntBlock = @bitCast(unmatches_bits); - { - @setRuntimeSafety(false); - if (unmatches_int == 0) unreachable; - } + const unmatches_int: simd.IntBlock = @bitCast(unmatches_bits); + if (unmatches_int != 0) { return it - ptr._ptr + @ctz(unmatches_int); } it += simd.BLOCK_LEN; @@ -260,13 +255,8 @@ pub fn PaddedMany(comptime PADDING_: usize) type { for (splats) |splat| { matches_bits |= @bitCast(block == splat); } - const matches_bools: simd.BoolBlock = @bitCast(matches_bits); - if (@reduce(.Or, matches_bools)) { - const matches_int: simd.IntBlock = @bitCast(matches_bits); - { - @setRuntimeSafety(false); - if (matches_int == 0) unreachable; - } + const matches_int: simd.IntBlock = @bitCast(matches_bits); + if (matches_int != 0) { return it - ptr._ptr + @ctz(matches_int); } it += simd.BLOCK_LEN;