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>,
)
| 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 | /// |
no test coverage detected