reduces constant overhead
(
&mut self,
q: &mut SparseSet,
empty_flags: EmptyFlags,
state_flags: StateFlags,
)
| 1391 | /// This may return STATE_DEAD but never STATE_UNKNOWN. |
| 1392 | #[inline(always)] // reduces constant overhead |
| 1393 | fn start_state( |
| 1394 | &mut self, |
| 1395 | q: &mut SparseSet, |
| 1396 | empty_flags: EmptyFlags, |
| 1397 | state_flags: StateFlags, |
| 1398 | ) -> Option<StatePtr> { |
| 1399 | // Compute an index into our cache of start states based on the set |
| 1400 | // of empty/state flags set at the current position in the input. We |
| 1401 | // don't use every flag since not all flags matter. For example, since |
| 1402 | // matches are delayed by one byte, start states can never be match |
| 1403 | // states. |
| 1404 | let flagi = { |
| 1405 | (((empty_flags.start as u8) << 0) | |
| 1406 | ((empty_flags.end as u8) << 1) | |
| 1407 | ((empty_flags.start_line as u8) << 2) | |
| 1408 | ((empty_flags.end_line as u8) << 3) | |
| 1409 | ((empty_flags.word_boundary as u8) << 4) | |
| 1410 | ((empty_flags.not_word_boundary as u8) << 5) | |
| 1411 | ((state_flags.is_word() as u8) << 6)) |
| 1412 | as usize |
| 1413 | }; |
| 1414 | match self.cache.start_states[flagi] { |
| 1415 | STATE_UNKNOWN => {} |
| 1416 | STATE_DEAD => return Some(STATE_DEAD), |
| 1417 | si => return Some(si), |
| 1418 | } |
| 1419 | q.clear(); |
| 1420 | let start = usize_to_u32(self.prog.start); |
| 1421 | self.follow_epsilons(start, q, empty_flags); |
| 1422 | // Start states can never be match states because we delay every match |
| 1423 | // by one byte. Given an empty string and an empty match, the match |
| 1424 | // won't actually occur until the DFA processes the special EOF |
| 1425 | // sentinel byte. |
| 1426 | let sp = match self.cached_state(q, state_flags, None) { |
| 1427 | None => return None, |
| 1428 | Some(sp) => self.start_ptr(sp), |
| 1429 | }; |
| 1430 | self.cache.start_states[flagi] = sp; |
| 1431 | Some(sp) |
| 1432 | } |
| 1433 | |
| 1434 | /// Computes the set of starting flags for the given position in text. |
| 1435 | /// |
no test coverage detected