Prune comments
This commit is contained in:
parent
6eb5c5e46a
commit
a9ede8828c
78
src/lib.rs
78
src/lib.rs
|
@ -99,30 +99,7 @@ const ASCII_DIGITS_SIMD: *const i32 = &__ASCII_DIGITS_SIMD as *const u32 as *con
|
|||
/// Returns [`INVALID_BIT`] if invalid. Based on `char.to_digit()` in the stdlib.
|
||||
#[inline]
|
||||
pub const fn hex_digit(ascii: u8) -> u8 {
|
||||
// use core::ops::RangeInclusive;
|
||||
// const DIGIT_MIN: u8 = '0' as u8;
|
||||
// const DIGIT_MAX: u8 = '9' as u8;
|
||||
// const LOWER_MIN: u8 = 'a' as u8;
|
||||
// const LOWER_MAX: u8 = 'f' as u8;
|
||||
// const UPPER_MIN: u8 = 'A' as u8;
|
||||
// const UPPER_MAX: u8 = 'F' as u8;
|
||||
// match ascii {
|
||||
// DIGIT_MIN..=DIGIT_MAX => ascii - DIGIT_MIN,
|
||||
// LOWER_MIN..=LOWER_MAX => 10 + ascii - LOWER_MIN,
|
||||
// UPPER_MIN..=UPPER_MAX => 10 + ascii - UPPER_MIN,
|
||||
// _ => INVALID_BIT,
|
||||
// }
|
||||
ASCII_DIGITS[ascii as usize]
|
||||
// let mut digit = ascii.wrapping_sub('0' as u8);
|
||||
// if digit < 10 {
|
||||
// return digit;
|
||||
// }
|
||||
// // Force the 6th bit to be set to ensure ascii is lower case.
|
||||
// digit = (ascii | 0b10_0000).wrapping_sub('a' as u8);
|
||||
// if digit < 6 {
|
||||
// return digit + 10;
|
||||
// }
|
||||
// return INVALID_BIT;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -203,13 +180,6 @@ impl HexByteSimdDecoder for HexByteDecoderA {
|
|||
}
|
||||
let msb = simd_swizzle!(hex_digits, MSB_INDICES);
|
||||
let lsb = simd_swizzle!(hex_digits, LSB_INDICES);
|
||||
/*let msb = msb.cast::<u16>();
|
||||
let lsb = lsb.cast::<u16>();
|
||||
let buf = msb << simd::splat_n::<WIDE_BATCH_SIZE>(4) | lsb | ((lsb & simd::splat_n::<WIDE_BATCH_SIZE>(0xf0)) << simd::splat_n::<WIDE_BATCH_SIZE>(8));
|
||||
if buf.simd_gt(simd::splat_n::<WIDE_BATCH_SIZE>(u8::MAX as u16)).any() {
|
||||
return None;
|
||||
}
|
||||
Some(buf.cast::<u8>())*/
|
||||
Some((msb << simd::splat_n::<WIDE_BATCH_SIZE>(4)) | lsb)
|
||||
}
|
||||
}
|
||||
|
@ -336,9 +306,6 @@ macro_rules! hex_digits_simd_inline {
|
|||
|
||||
macro_rules! merge_hex_digits_into_bytes_inline {
|
||||
($hex_digits:ident) => {{
|
||||
//let hex_digits = Simd::<u8, DIGIT_BATCH_SIZE>::from($hex_digits);
|
||||
//let msb = simd_swizzle!(hex_digits, MSB_INDICES);
|
||||
//let lsb = simd_swizzle!(hex_digits, LSB_INDICES);
|
||||
let msb = simd::extract_lo_bytes($hex_digits);
|
||||
let lsb = simd::extract_hi_bytes($hex_digits);
|
||||
|
||||
|
@ -348,8 +315,6 @@ macro_rules! merge_hex_digits_into_bytes_inline {
|
|||
let msb1: Simd<u8, WIDE_BATCH_SIZE> = msb1.into();
|
||||
println!("msb1: {msb1:x?}");
|
||||
}
|
||||
//let msb2: simd::arch::__m128i;
|
||||
//unsafe { std::arch::asm!("vpand {dst}, {src}, 0x0000_0000_0000_0000_0000_0000_0000_f0f0", src = in(xmm_reg) msb1, dst = lateout(xmm_reg) msb2) };
|
||||
let msb2 = msb1.and(Simd::from_array([0xf0f0u16; WIDE_BATCH_SIZE / 2]).into());
|
||||
let b = msb2.or(lsb);
|
||||
|
||||
|
@ -383,36 +348,6 @@ macro_rules! merge_hex_digits_into_bytes_inline {
|
|||
}
|
||||
|
||||
b
|
||||
|
||||
/*let msb = simd::extract_lo_bytes($hex_digits);
|
||||
let lsb = simd::extract_hi_bytes($hex_digits);
|
||||
|
||||
let msb: Simd<u8, WIDE_BATCH_SIZE> = msb.into();
|
||||
let lsb: Simd<u8, WIDE_BATCH_SIZE> = lsb.into();
|
||||
|
||||
if_trace_simd! {
|
||||
println!("msb: {msb:x?}");
|
||||
println!("lsb: {lsb:x?}");
|
||||
println!("| Packed | Msb | Lsb | |");
|
||||
Simd::<u8, DIGIT_BATCH_SIZE>::from(hex_digits)
|
||||
.to_array()
|
||||
.chunks(2)
|
||||
.zip(msb.to_array())
|
||||
.zip(lsb.to_array())
|
||||
.for_each(|((chunk, msb), lsb)| {
|
||||
println!(
|
||||
"| {chunk:02x?} | {msb:x?} | {lsb:x?} | {ok} |",
|
||||
chunk = (chunk[0] as u16) << 4 | (chunk[1] as u16),
|
||||
ok = if chunk[0] == msb && chunk[1] == lsb {
|
||||
'✓'
|
||||
} else {
|
||||
'✗'
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
//simd::merge_lo_hi_m128(msb, lsb)
|
||||
simd::arch::__m128i::from((msb << simd::splat_n::<WIDE_BATCH_SIZE>(4)) | lsb)*/
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -480,16 +415,12 @@ macro_rules! decode_hex_bytes_non_vectored {
|
|||
let hi = hex_digit(hi);
|
||||
bad |= lo;
|
||||
bad |= hi;
|
||||
/*if (hi & INVALID_BIT) | (lo & INVALID_BIT) != 0 {
|
||||
println!("bad hex byte at {} ({}{})", $i, $ascii[$i] as char, $ascii[$i + 1] as char);
|
||||
}*/
|
||||
let b = (hi << 4) | lo;
|
||||
unsafe { *$bytes.get_unchecked_mut($i >> 1) = MaybeUninit::new(b) };
|
||||
|
||||
/*match unsafe { hex_byte(*$ascii.get_unchecked($i), *$ascii.get_unchecked($i + 1)) } {
|
||||
Some(b) => unsafe { *$bytes.get_unchecked_mut($i >> 1) = MaybeUninit::new(b) },
|
||||
None => {
|
||||
//println!("bad hex byte at {} ({}{})", $i, $ascii[$i] as char, $ascii[$i + 1] as char);
|
||||
return false
|
||||
}
|
||||
}*/
|
||||
$i += 2;
|
||||
}
|
||||
//if (bad & WIDE_INVALID_BIT) != 0 {
|
||||
|
@ -554,9 +485,6 @@ fn decode_hex_bytes_unchecked(ascii: &[u8], bytes: &mut [MaybeUninit<u8>]) -> bo
|
|||
|
||||
let buf = merge_hex_digits_into_bytes_inline!(hex_digits);
|
||||
|
||||
//let buf: arch::__m128i = unsafe { util::cast(buf) };
|
||||
//let buf: arch::__m128i = buf.into();
|
||||
|
||||
unsafe {
|
||||
// vmovaps xmm0, xmmword ptr [rsi]
|
||||
// vmovups xmmword ptr [rdi], xmm0
|
||||
|
|
Loading…
Reference in New Issue