Skip to content

Commit e674250

Browse files
committed
Update stdsimd code
1 parent 2871fa4 commit e674250

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

src/stdsimd.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,20 @@
22

33
use crate::{Needle, NeedleWithSize, Searcher, Vector, VectorHash};
44
#[cfg(feature = "stdsimd")]
5-
use std::simd::*;
5+
use std::simd::{cmp::SimdPartialEq, *};
66

7-
trait ToFixedBitMask: Sized {
8-
fn to_fixed_bitmask(self) -> u32;
9-
}
7+
trait SupportedMaskLateCount {}
108

11-
impl<const LANES: usize> ToFixedBitMask for Mask<i8, LANES>
12-
where
13-
LaneCount<LANES>: SupportedLaneCount,
14-
Self: ToBitMask,
15-
<Self as ToBitMask>::BitMask: Into<u32>,
16-
{
17-
#[inline]
18-
fn to_fixed_bitmask(self) -> u32 {
19-
self.to_bitmask().into()
20-
}
21-
}
9+
impl SupportedMaskLateCount for LaneCount<2> {}
10+
impl SupportedMaskLateCount for LaneCount<4> {}
11+
impl SupportedMaskLateCount for LaneCount<8> {}
12+
impl SupportedMaskLateCount for LaneCount<16> {}
13+
impl SupportedMaskLateCount for LaneCount<32> {}
2214

2315
impl<const LANES: usize> Vector for Simd<u8, LANES>
2416
where
2517
LaneCount<LANES>: SupportedLaneCount,
26-
Mask<i8, LANES>: ToFixedBitMask,
18+
LaneCount<LANES>: SupportedMaskLateCount,
2719
{
2820
const LANES: usize = LANES;
2921
type Mask = Mask<i8, LANES>;
@@ -50,7 +42,7 @@ where
5042

5143
#[inline]
5244
unsafe fn to_bitmask(a: Self::Mask) -> u32 {
53-
a.to_fixed_bitmask()
45+
a.to_bitmask() as u32
5446
}
5547
}
5648

@@ -65,9 +57,9 @@ fn from_hash<const N1: usize, const N2: usize>(
6557
) -> VectorHash<Simd<u8, N2>>
6658
where
6759
LaneCount<N1>: SupportedLaneCount,
68-
Mask<i8, N1>: ToFixedBitMask,
60+
LaneCount<N1>: SupportedMaskLateCount,
6961
LaneCount<N2>: SupportedLaneCount,
70-
Mask<i8, N2>: ToFixedBitMask,
62+
LaneCount<N2>: SupportedMaskLateCount,
7163
{
7264
VectorHash {
7365
first: Simd::splat(hash.first.as_array()[0]),

0 commit comments

Comments
 (0)