use std::num::NonZero;
use std::sync::Arc;
use rustc_hash::FxHashMap;
pub const BYTE_CEILING: usize = 0xF6;
pub const BYTE_CEILING_U8: u8 = 0xF6;
pub const VALUE_TERMINATOR: u8 = 0xF5;
#[derive(Clone, Debug, Default)]
pub struct AccelInfo {
pub exit_bytes: [u8; 3],
pub len: u8,
}
impl AccelInfo {
#[inline]
#[must_use]
pub fn try_accelerate(&self, remaining: &[u8]) -> Option<NonZero<usize>> {
let offset = match self.len {
1 => memchr::memchr(self.exit_bytes[0], remaining),
2 => memchr::memchr2(self.exit_bytes[0], self.exit_bytes[1], remaining),
3 => memchr::memchr3(
self.exit_bytes[0],
self.exit_bytes[1],
self.exit_bytes[2],
remaining,
),
_ => None,
}?;
NonZero::new(offset)
}
}
#[derive(Clone, Default)]
pub struct FieldMatcher {
pub match_id: Option<u64>,
pub exists_true: FxHashMap<String, Arc<Self>>,
pub exists_false: FxHashMap<String, Arc<Self>>,
}
impl FieldMatcher {
#[must_use]
pub fn new() -> Self {
Self {
match_id: None,
exists_true: FxHashMap::default(),
exists_false: FxHashMap::default(),
}
}
#[must_use]
pub fn with_match_id(id: u64) -> Self {
Self {
match_id: Some(id),
exists_true: FxHashMap::default(),
exists_false: FxHashMap::default(),
}
}
}
#[derive(Default)]
pub struct NfaBuffers {
pub arena_bufs: super::arena::NfaBuffers,
}
impl NfaBuffers {
#[must_use]
pub fn new() -> Self {
Self {
arena_bufs: super::arena::NfaBuffers::new(),
}
}
pub fn clear(&mut self) {
self.arena_bufs.clear();
}
}