File tree Expand file tree Collapse file tree 4 files changed +15
-16
lines changed
swc_ecma_parser/src/lexer Expand file tree Collapse file tree 4 files changed +15
-16
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ swc_core : patch
3+ swc_ecma_lexer : patch
4+ ---
5+
6+ less compute in next token
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ impl<'a> StringInput<'a> {
5656 self . orig_start
5757 }
5858
59+ #[ inline( always) ]
5960 pub fn end_pos ( & self ) -> BytePos {
6061 self . orig_end
6162 }
Original file line number Diff line number Diff line change @@ -759,15 +759,11 @@ impl Lexer<'_> {
759759 * start = self . input . cur_pos ( ) ;
760760 } ;
761761
762- match self . input . cur ( ) {
763- Some ( ..) => { }
762+ if self . input . last_pos ( ) == self . input . end_pos ( ) {
764763 // End of input.
765- None => {
766- self . consume_pending_comments ( ) ;
767-
768- return Ok ( None ) ;
769- }
770- } ;
764+ self . consume_pending_comments ( ) ;
765+ return Ok ( None ) ;
766+ }
771767
772768 // println!(
773769 // "\tContext: ({:?}) {:?}",
Original file line number Diff line number Diff line change @@ -378,15 +378,11 @@ impl Lexer<'_> {
378378 self . skip_space :: < true > ( ) ;
379379 * start = self . input . cur_pos ( ) ;
380380
381- match self . input . cur ( ) {
382- Some ( ..) => { }
381+ if self . input . last_pos ( ) == self . input . end_pos ( ) {
383382 // End of input.
384- None => {
385- self . consume_pending_comments ( ) ;
386-
387- return Ok ( None ) ;
388- }
389- } ;
383+ self . consume_pending_comments ( ) ;
384+ return Ok ( None ) ;
385+ }
390386
391387 // println!(
392388 // "\tContext: ({:?}) {:?}",
You can’t perform that action at this time.
0 commit comments