Skip to content

Commit dc02eac

Browse files
committed
cleanup
1 parent d5ed064 commit dc02eac

File tree

3 files changed

+5
-52
lines changed

3 files changed

+5
-52
lines changed

portable/src/implementation/helpers.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,3 @@ pub(crate) fn get_compat_error(input: &[u8], failing_block_pos: usize) -> Utf8Er
3636
// UNWRAP: safe because the SIMD UTF-8 validation found an error
3737
validate_utf8_at_offset(input, offset).unwrap_err()
3838
}
39-
40-
pub(crate) const SIMD_CHUNK_SIZE: usize = 64;
41-
42-
#[repr(C, align(32))]
43-
#[allow(dead_code)] // only used if there is a SIMD implementation
44-
pub(crate) struct Utf8CheckAlgorithm<T> {
45-
pub(crate) prev: T,
46-
pub(crate) incomplete: T,
47-
pub(crate) error: T,
48-
}
49-
50-
#[repr(C, align(16))]
51-
#[allow(dead_code)] // only used if a 128-bit SIMD implementation is used
52-
pub(crate) struct TempSimdChunkA16(pub(crate) [u8; SIMD_CHUNK_SIZE]);
53-
54-
#[allow(dead_code)] // only used if there is a SIMD implementation
55-
impl TempSimdChunkA16 {
56-
#[expect(clippy::inline_always)]
57-
#[inline(always)] // needs to be forced because otherwise it is not inlined on armv7 neo
58-
pub(crate) const fn new() -> Self {
59-
Self([0; SIMD_CHUNK_SIZE])
60-
}
61-
}
62-
63-
#[repr(C, align(32))]
64-
#[allow(dead_code)] // only used if a 256-bit SIMD implementation is used
65-
pub(crate) struct TempSimdChunkA32(pub(crate) [u8; SIMD_CHUNK_SIZE]);
66-
67-
#[allow(dead_code)] // only used if there is a SIMD implementation
68-
impl TempSimdChunkA32 {
69-
#[expect(clippy::inline_always)]
70-
#[inline(always)] // needs to be forced because otherwise it is not inlined on armv7 neo
71-
pub(crate) const fn new() -> Self {
72-
Self([0; SIMD_CHUNK_SIZE])
73-
}
74-
}
75-
76-
#[derive(Clone, Copy)]
77-
#[allow(dead_code)] // only used if there is a SIMD implementation
78-
pub(crate) struct SimdU8Value<T>(pub(crate) T)
79-
where
80-
T: Copy;

portable/src/implementation/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub(crate) mod simd;
77

88
#[inline]
99
pub(crate) fn validate_utf8_basic(input: &[u8]) -> Result<(), crate::basic::Utf8Error> {
10-
if input.len() < helpers::SIMD_CHUNK_SIZE {
10+
if input.len() < simd::SIMD_CHUNK_SIZE {
1111
return validate_utf8_basic_fallback(input);
1212
}
1313

@@ -24,7 +24,7 @@ fn validate_utf8_basic_simd(input: &[u8]) -> Result<(), crate::basic::Utf8Error>
2424

2525
#[inline]
2626
pub(crate) fn validate_utf8_compat(input: &[u8]) -> Result<(), crate::compat::Utf8Error> {
27-
if input.len() < helpers::SIMD_CHUNK_SIZE {
27+
if input.len() < simd::SIMD_CHUNK_SIZE {
2828
return validate_utf8_compat_fallback(input);
2929
}
3030

portable/src/implementation/simd.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use std::simd::{
44
simd_swizzle, u8x16, LaneCount, Simd, SupportedLaneCount,
55
};
66

7-
use crate::{basic, compat, implementation::helpers::SIMD_CHUNK_SIZE};
7+
use crate::{basic, compat};
8+
9+
pub(crate) const SIMD_CHUNK_SIZE: usize = 64;
810

911
#[cfg(all(
1012
any(target_arch = "aarch64", target_arch = "arm"),
@@ -562,7 +564,6 @@ where
562564
///
563565
#[inline]
564566
pub fn validate_utf8_basic(input: &[u8]) -> core::result::Result<(), basic::Utf8Error> {
565-
use crate::implementation::helpers::SIMD_CHUNK_SIZE;
566567
let mut algorithm = Self::new();
567568
let mut chunks = input.chunks_exact(SIMD_CHUNK_SIZE);
568569
for chunk in chunks.by_ref() {
@@ -593,7 +594,6 @@ where
593594
#[inline]
594595
#[expect(clippy::redundant_else)] // more readable
595596
fn validate_utf8_compat_simd0(input: &[u8]) -> core::result::Result<(), usize> {
596-
use crate::implementation::helpers::SIMD_CHUNK_SIZE;
597597
let mut algorithm = Self::new();
598598
let mut idx = 0;
599599
let mut chunks = input.chunks_exact(SIMD_CHUNK_SIZE);
@@ -709,7 +709,6 @@ impl basic::imp::Utf8Validator for Utf8ValidatorImp {
709709

710710
#[inline]
711711
fn update(&mut self, mut input: &[u8]) {
712-
use crate::implementation::helpers::SIMD_CHUNK_SIZE;
713712
if input.is_empty() {
714713
return;
715714
}
@@ -779,8 +778,6 @@ impl basic::imp::ChunkedUtf8Validator for ChunkedUtf8ValidatorImp {
779778

780779
#[inline]
781780
fn update_from_chunks(&mut self, input: &[u8]) {
782-
use crate::implementation::helpers::SIMD_CHUNK_SIZE;
783-
784781
assert!(
785782
input.len() % SIMD_CHUNK_SIZE == 0,
786783
"Input size must be a multiple of 64."
@@ -796,8 +793,6 @@ impl basic::imp::ChunkedUtf8Validator for ChunkedUtf8ValidatorImp {
796793
mut self,
797794
remaining_input: core::option::Option<&[u8]>,
798795
) -> core::result::Result<(), basic::Utf8Error> {
799-
use crate::implementation::helpers::SIMD_CHUNK_SIZE;
800-
801796
if let Some(mut remaining_input) = remaining_input {
802797
if !remaining_input.is_empty() {
803798
let len = remaining_input.len();

0 commit comments

Comments
 (0)