@@ -160,23 +160,17 @@ pub(crate) struct Match<'m> {
160
160
pub params : HashMap < & ' static str , & ' m str > ,
161
161
}
162
162
163
- #[ derive( Default ) ]
164
- struct StartParse {
165
- should_start : bool ,
166
- name : Option < & ' static str > ,
167
- }
168
-
169
163
pub ( crate ) struct StateMachine {
170
164
states : Vec < State > ,
171
- start_parse : Vec < StartParse > ,
165
+ start_parse : Vec < Option < & ' static str > > ,
172
166
end_parse : Vec < bool > ,
173
167
}
174
168
175
169
impl StateMachine {
176
170
pub ( crate ) fn new ( ) -> Self {
177
171
Self {
178
172
states : vec ! [ State :: new( 0 , CharacterSet :: new( ) ) ] ,
179
- start_parse : vec ! [ StartParse :: default ( ) ] ,
173
+ start_parse : vec ! [ None ] ,
180
174
end_parse : vec ! [ false ] ,
181
175
}
182
176
}
@@ -209,7 +203,7 @@ impl StateMachine {
209
203
let state = State :: new ( index, expected) ;
210
204
211
205
self . states . push ( state) ;
212
- self . start_parse . push ( StartParse :: default ( ) ) ;
206
+ self . start_parse . push ( None ) ;
213
207
self . end_parse . push ( false ) ;
214
208
index
215
209
}
@@ -228,9 +222,7 @@ impl StateMachine {
228
222
/// Mark that the index in the state machine is a state to start parsing a dynamic
229
223
/// segment.
230
224
pub ( crate ) fn start_parse ( & mut self , index : usize , name : & ' static str ) {
231
- let parse = & mut self . start_parse [ index] ;
232
- parse. should_start = true ;
233
- parse. name = Some ( name) ;
225
+ self . start_parse [ index] = Some ( name) ;
234
226
}
235
227
236
228
/// Mark that the index in the state machine is a state to stop parsing a dynamic
@@ -326,8 +318,8 @@ impl StateMachine {
326
318
) {
327
319
let start_parse = & self . start_parse [ next_state] ;
328
320
329
- if traversal. segment_start . is_none ( ) && start_parse. should_start {
330
- traversal. set_segment_start ( pos, start_parse. name . unwrap ( ) ) ;
321
+ if traversal. segment_start . is_none ( ) && start_parse. is_some ( ) {
322
+ traversal. set_segment_start ( pos, start_parse. unwrap ( ) ) ;
331
323
}
332
324
if traversal. segment_start . is_some ( )
333
325
&& self . end_parse [ current_state]
0 commit comments