MCPcopy Create free account
hub / github.com/davidblewett/rure-python / clear_cache_and_save

Method clear_cache_and_save

regex/src/dfa.rs:1278–1300  ·  view source on GitHub ↗

Clears the cache, but saves and restores current_state if it is not none. The current state must be provided here in case its location in the cache changes. This returns false if the cache is not cleared and the DFA should give up.

(
        &mut self,
        current_state: Option<&mut StatePtr>,
    )

Source from the content-addressed store, hash-verified

1276 /// This returns false if the cache is not cleared and the DFA should
1277 /// give up.
1278 fn clear_cache_and_save(
1279 &mut self,
1280 current_state: Option<&mut StatePtr>,
1281 ) -> bool {
1282 if self.cache.compiled.is_empty() {
1283 // Nothing to clear...
1284 return true;
1285 }
1286 match current_state {
1287 None => self.clear_cache(),
1288 Some(si) => {
1289 let cur = self.state(*si).clone();
1290 if !self.clear_cache() {
1291 return false;
1292 }
1293 // The unwrap is OK because we just cleared the cache and
1294 // therefore know that the next state pointer won't exceed
1295 // STATE_MAX.
1296 *si = self.restore_state(cur).unwrap();
1297 true
1298 }
1299 }
1300 }
1301
1302 /// Wipes the state cache, but saves and restores the current start state.
1303 ///

Callers 1

cached_stateMethod · 0.80

Calls 6

clear_cacheMethod · 0.80
cloneMethod · 0.80
stateMethod · 0.80
unwrapMethod · 0.80
restore_stateMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected