From 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:03:36 +0200 Subject: Adding upstream version 1.65.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/regex/src/dfa.rs | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'vendor/regex/src/dfa.rs') diff --git a/vendor/regex/src/dfa.rs b/vendor/regex/src/dfa.rs index 4aee8039c..dc9952120 100644 --- a/vendor/regex/src/dfa.rs +++ b/vendor/regex/src/dfa.rs @@ -31,7 +31,7 @@ considerably more complex than one might expect out of a DFA. A number of tricks are employed to make it fast. Tread carefully. N.B. While this implementation is heavily commented, Russ Cox's series of -articles on regexes is strongly recommended: https://swtch.com/~rsc/regexp/ +articles on regexes is strongly recommended: (As is the DFA implementation in RE2, which heavily influenced this implementation.) */ @@ -454,10 +454,10 @@ impl<'a> Fsm<'a> { let mut cache = cache.borrow_mut(); let cache = &mut cache.dfa; let mut dfa = Fsm { - prog: prog, + prog, start: 0, // filled in below - at: at, - quit_after_match: quit_after_match, + at, + quit_after_match, last_match_si: STATE_UNKNOWN, last_cache_flush: at, cache: &mut cache.inner, @@ -484,10 +484,10 @@ impl<'a> Fsm<'a> { let mut cache = cache.borrow_mut(); let cache = &mut cache.dfa_reverse; let mut dfa = Fsm { - prog: prog, + prog, start: 0, // filled in below - at: at, - quit_after_match: quit_after_match, + at, + quit_after_match, last_match_si: STATE_UNKNOWN, last_cache_flush: at, cache: &mut cache.inner, @@ -515,9 +515,9 @@ impl<'a> Fsm<'a> { let mut cache = cache.borrow_mut(); let cache = &mut cache.dfa; let mut dfa = Fsm { - prog: prog, + prog, start: 0, // filled in below - at: at, + at, quit_after_match: false, last_match_si: STATE_UNKNOWN, last_cache_flush: at, @@ -1606,11 +1606,7 @@ struct StateMap { impl StateMap { fn new(num_byte_classes: usize) -> StateMap { - StateMap { - map: HashMap::new(), - states: vec![], - num_byte_classes: num_byte_classes, - } + StateMap { map: HashMap::new(), states: vec![], num_byte_classes } } fn len(&self) -> usize { @@ -1646,7 +1642,7 @@ impl Transitions { /// The number of byte classes corresponds to the stride. Every state will /// have `num_byte_classes` slots for transitions. fn new(num_byte_classes: usize) -> Transitions { - Transitions { table: vec![], num_byte_classes: num_byte_classes } + Transitions { table: vec![], num_byte_classes } } /// Returns the total number of states currently in this table. @@ -1696,27 +1692,27 @@ impl Transitions { impl StateFlags { fn is_match(&self) -> bool { - self.0 & 0b0000000_1 > 0 + self.0 & 0b0000_0001 > 0 } fn set_match(&mut self) { - self.0 |= 0b0000000_1; + self.0 |= 0b0000_0001; } fn is_word(&self) -> bool { - self.0 & 0b000000_1_0 > 0 + self.0 & 0b0000_0010 > 0 } fn set_word(&mut self) { - self.0 |= 0b000000_1_0; + self.0 |= 0b0000_0010; } fn has_empty(&self) -> bool { - self.0 & 0b00000_1_00 > 0 + self.0 & 0b0000_0100 > 0 } fn set_empty(&mut self) { - self.0 |= 0b00000_1_00; + self.0 |= 0b0000_0100; } } -- cgit v1.2.3