| 1 | #[cfg(target_feature = "simd128")] |
| 2 | #[allow(dead_code)] |
| 3 | pub(crate) mod simd128; |
| 4 | |
| 5 | #[inline] |
| 6 | #[cfg(target_feature = "simd128")] |
| 7 | pub(crate) unsafe fn validate_utf8_basic(input: &[u8]) -> Result<(), crate::basic::Utf8Error> { |
| 8 | if input.len() < super::helpers::SIMD_CHUNK_SIZE { |
| 9 | return super::validate_utf8_basic_fallback(input); |
| 10 | } |
| 11 | |
| 12 | validate_utf8_basic_simd128(input) |
| 13 | } |
| 14 | |
| 15 | #[inline(never)] |
| 16 | #[cfg(target_feature = "simd128")] |
| 17 | unsafe fn validate_utf8_basic_simd128(input: &[u8]) -> Result<(), crate::basic::Utf8Error> { |
| 18 | simd128::validate_utf8_basic(input) |
| 19 | } |
| 20 | |
| 21 | #[cfg(not(target_feature = "simd128"))] |
| 22 | pub(crate) use super::validate_utf8_basic_fallback as validate_utf8_basic; |
| 23 | |
| 24 | #[inline] |
| 25 | #[cfg(target_feature = "simd128")] |
| 26 | pub(crate) unsafe fn validate_utf8_compat(input: &[u8]) -> Result<(), crate::compat::Utf8Error> { |
| 27 | if input.len() < super::helpers::SIMD_CHUNK_SIZE { |
| 28 | return super::validate_utf8_compat_fallback(input); |
| 29 | } |
| 30 | |
| 31 | validate_utf8_compat_simd128(input) |
| 32 | } |
| 33 | |
| 34 | #[inline(never)] |
| 35 | #[cfg(target_feature = "simd128")] |
| 36 | unsafe fn validate_utf8_compat_simd128(input: &[u8]) -> Result<(), crate::compat::Utf8Error> { |
| 37 | simd128::validate_utf8_compat(input) |
| 38 | } |
| 39 | |
| 40 | #[cfg(not(target_feature = "simd128"))] |
| 41 | pub(crate) use super::validate_utf8_compat_fallback as validate_utf8_compat; |