fn cached_state(
        &mut self,
        q: &SparseSet,
        mut state_flags: StateFlags,
        current_state: Option<&mut StatePtr>,
    ) -> Option<StatePtr> {
        // If we couldn't come up with a non-empty key to represent this state,
        // then it is dead and can never lead to a match.
        //
        // Note that inst_flags represent the set of empty width assertions
        // in q. We use this as an optimization in exec_byte to determine when
        // we should follow epsilon transitions at the empty string preceding
        // the current byte.
        let key = match self.cached_state_key(q, &mut state_flags) {
            None => return Some(STATE_DEAD),
            Some(v) => v,
        };
        // In the cache? Cool. Done.
        if let Some(&si) = self.cache.compiled.get(&key) {
            return Some(si);
        }

        // If the cache has gotten too big, wipe it.
        if self.approximate_size() > CACHE_LIMIT {
            if !self.clear_cache_and_save(current_state) {
                // Ooops. DFA is giving up.
                return None;
            }
        }

        // OK, now there's enough room to push our new state.
        // We do this even if the cache size is set to 0!
        let next = vec![STATE_UNKNOWN; self.num_byte_classes()];
        self.cache.states.push(State {
            next: next.into_boxed_slice(),
            insts: key.insts.clone(),
            flags: state_flags,
        });
        let si = usize_to_u32(self.cache.states.len().checked_sub(1).unwrap());
        self.cache.compiled.insert(key, si);
        Some(si)
    }
/// Find a previously computed state matching the given set of instructions
/// and is_match bool.
///
/// The given set of instructions should represent a single state in the
/// NFA along with all states reachable without consuming any input.
///
/// The is_match bool should be true if and only if the preceding DFA state
/// contains an NFA matching state. The cached state produced here will
/// then signify a match. (This enables us to delay a match by one byte,
/// in order to account for the EOF sentinel byte.)
///
/// If the cache is full, then it is wiped before caching a new state.
///
/// The current state should be specified if it exists, since it will need
/// to be preserved if the cache clears itself. (Start states are
/// always saved, so they should not be passed here.) It takes a mutable
/// pointer to the index because if the cache is cleared, the state's
/// location may change.
Find a previously computed state matching the given set of instructions
and is_match bool.

The given set of instructions should represent a single state in the
NFA along with all states reachable without consuming any input.

The is_match bool should be true if and only if the preceding DFA state
contains an NFA matching state. The cached state produced here will
then signify a match. (This enables us to delay a match by one byte,
in order to account for the EOF sentinel byte.)

If the cache is full, then it is wiped before caching a new state.

The current state should be specified if it exists, since it will need
to be preserved if the cache clears itself. (Start states are
always saved, so they should not be passed here.) It takes a mutable
pointer to the index because if the cache is cleared, the state's
location may change.
Find a previously computed state matching the given set of instructions and is_match bool . The given set of instructions should represent a single state in the NFA along with all states reachable without consuming any input . The is_match bool should be true if and only if the preceding DFA state contains an NFA matching state . The cached state produced here will then signify a match . ( This enables us to delay a match by one byte in order to account for the EOF sentinel byte . ) If the cache is full then it is wiped before caching a new state . The current state should be specified if it exists since it will need to be preserved if the cache clears itself . ( Start states are always saved so they should not be passed here . ) It takes a mutable pointer to the index because if the cache is cleared the state ' s location may change .
fn cached_state(
        &mut self,
        q: &SparseSet,
        mut state_flags: StateFlags,
        current_state: Option<&mut StatePtr>,
    ) -> Option<StatePtr> {
        // If we couldn't come up with a non-empty key to represent this state,
        // then it is dead and can never lead to a match.
        //
        // Note that inst_flags represent the set of empty width assertions
        // in q. We use this as an optimization in exec_byte to determine when
        // we should follow epsilon transitions at the empty string preceding
        // the current byte.
        let key = match self.cached_state_key(q, &mut state_flags) {
            None => return Some(STATE_DEAD),
            Some(v) => v,
        };
        // In the cache? Cool. Done.
        if let Some(&si) = self.cache.compiled.get(&key) {
            return Some(si);
        }
        // If the cache has gotten too big, wipe it.
        if self.approximate_size() > CACHE_LIMIT {
            if !self.clear_cache_and_save(current_state) {
                // Ooops. DFA is giving up.
                return None;
            }
        }
        // OK, now there's enough room to push our new state.
        // We do this even if the cache size is set to 0!
        let next = vec![STATE_UNKNOWN; self.num_byte_classes()];
        self.cache.states.push(State {
            next: next.into_boxed_slice(),
            insts: key.insts.clone(),
            flags: state_flags,
        });
        let si = usize_to_u32(self.cache.states.len().checked_sub(1).unwrap());
        self.cache.compiled.insert(key, si);
        Some(si)
    }
fn cached_state ( & mut self , q : & SparseSet , mut state_flags : StateFlags , current_state : Option < & mut StatePtr > , ) -> Option < StatePtr > { // If we couldn't come up with a non-empty key to represent this state, // then it is dead and can never lead to a match. // // Note that inst_flags represent the set of empty width assertions // in q. We use this as an optimization in exec_byte to determine when // we should follow epsilon transitions at the empty string preceding // the current byte. let key = match self . cached_state_key ( q , & mut state_flags ) { None => return Some ( STATE_DEAD ) , Some ( v ) => v , } ; // In the cache? Cool. Done. if let Some ( & si ) = self . cache . compiled . get ( & key ) { return Some ( si ) ; } // If the cache has gotten too big, wipe it. if self . approximate_size ( ) > CACHE_LIMIT { if ! self . clear_cache_and_save ( current_state ) { // Ooops. DFA is giving up. return None ; } } // OK, now there's enough room to push our new state. // We do this even if the cache size is set to 0! let next = vec ! [ STATE_UNKNOWN self num_byte_classes ( ) ] ; self . cache . states . push ( State { next : next . into_boxed_slice ( ) , insts : key . insts . clone ( ) , flags : state_flags , } ) ; let si = usize_to_u32 ( self . cache . states . len ( ) . checked_sub ( 1 ) . unwrap ( ) ) ; self . cache . compiled . insert ( key , si ) ; Some ( si ) }
Find a previously computed state matching the given set of instructions
and is_match bool.
Find a previously computed state matching the given set of instructions and is_match bool .
&mut self
q
&SparseSet
state_flags
StateFlags
current_state
Option<&mut StatePtr>
&mut self
q
&SparseSet
state_flags
StateFlags
current_state
Option<&mut StatePtr>