@@ -175,8 +175,8 @@ pub struct Lexer<T: Iterator<Item = char>> {
175
175
pending : Vec < Spanned > ,
176
176
// The current location.
177
177
location : TextSize ,
178
- // The last emitted token.
179
- last_emitted : Option < Tok > ,
178
+ // Is the last token an equal sign?
179
+ last_token_is_equal : bool ,
180
180
// Lexer mode.
181
181
mode : Mode ,
182
182
}
@@ -235,7 +235,7 @@ where
235
235
pending : Vec :: with_capacity ( 5 ) ,
236
236
location : start,
237
237
window : CharWindow :: new ( input) ,
238
- last_emitted : None ,
238
+ last_token_is_equal : false ,
239
239
mode,
240
240
} ;
241
241
// Fill the window.
@@ -948,10 +948,7 @@ where
948
948
}
949
949
}
950
950
'%' => {
951
- if self . mode == Mode :: Jupyter
952
- && self . nesting == 0
953
- && matches ! ( self . last_emitted, Some ( Tok :: Equal ) )
954
- {
951
+ if self . mode == Mode :: Jupyter && self . nesting == 0 && self . last_token_is_equal {
955
952
self . lex_and_emit_magic_command ( ) ;
956
953
} else {
957
954
let tok_start = self . get_pos ( ) ;
@@ -1035,10 +1032,7 @@ where
1035
1032
}
1036
1033
}
1037
1034
'!' => {
1038
- if self . mode == Mode :: Jupyter
1039
- && self . nesting == 0
1040
- && matches ! ( self . last_emitted, Some ( Tok :: Equal ) )
1041
- {
1035
+ if self . mode == Mode :: Jupyter && self . nesting == 0 && self . last_token_is_equal {
1042
1036
self . lex_and_emit_magic_command ( ) ;
1043
1037
} else {
1044
1038
let tok_start = self . get_pos ( ) ;
@@ -1309,7 +1303,7 @@ where
1309
1303
1310
1304
// Helper function to emit a lexed token to the queue of tokens.
1311
1305
fn emit ( & mut self , spanned : Spanned ) {
1312
- self . last_emitted = Some ( spanned. 0 . clone ( ) ) ;
1306
+ self . last_token_is_equal = matches ! ( spanned. 0 , Tok :: Equal ) ;
1313
1307
self . pending . push ( spanned) ;
1314
1308
}
1315
1309
}
0 commit comments