use crate::util;
mod fallback;
#[cfg(feature = "portable-simd")]
mod portable;
#[inline]
pub fn is_closing(needle: u8) -> bool {
(needle == b'/') | (needle == b'>')
}
#[inline]
pub fn search_non_ident(haystack: &[u8]) -> Option<usize> {
#[cfg(feature = "portable-simd")]
{
portable::search_non_ident(haystack)
}
#[cfg(not(feature = "portable-simd"))]
{
fallback::search_non_ident(haystack)
}
}
#[inline]
pub fn find3(haystack: &[u8], needle: [u8; 3]) -> Option<usize> {
#[cfg(feature = "portable-simd")]
{
portable::find3(haystack, needle)
}
#[cfg(not(feature = "portable-simd"))]
{
memchr::memchr3(needle[0], needle[1], needle[2], haystack)
}
}
#[inline]
pub fn find(haystack: &[u8], needle: u8) -> Option<usize> {
#[cfg(feature = "portable-simd")]
{
portable::find(haystack, needle)
}
#[cfg(not(feature = "portable-simd"))]
{
memchr::memchr(needle, haystack)
}
}
pub fn matches_case_insensitive<const N: usize>(haystack: &[u8], needle: [u8; N]) -> bool {
if haystack.len() != N {
return false;
}
let mut mask = true;
for i in 0..N {
mask &= util::to_lower(haystack[i]) == needle[i];
}
mask
}