Skip to content

Commit

Permalink
scanner,checker: optimize Scanner.scan_remaining_text and Checker.exp…
Browse files Browse the repository at this point in the history
…r, based on branch prediction analysis (vlang#22823)
  • Loading branch information
felipensp authored Nov 11, 2024
1 parent a132d97 commit b76d05d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,6 @@ pub fn (mut c Checker) expr(mut node ast.Expr) ast.Type {
return ast.void_type
}
match mut node {
ast.NodeError {}
ast.ComptimeType {
c.error('incorrect use of compile-time type', node.pos)
}
Expand Down Expand Up @@ -3182,6 +3181,7 @@ pub fn (mut c Checker) expr(mut node ast.Expr) ast.Type {
}
return ast.bool_type
}
ast.NodeError {}
}
return ast.void_type
}
Expand Down
12 changes: 6 additions & 6 deletions vlib/v/scanner/scanner.v
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,14 @@ fn (mut s Scanner) scan_all_tokens_in_buffer() {
}

fn (mut s Scanner) scan_remaining_text() {
is_skip_comments := s.comments_mode == .skip_comments
for {
t := s.text_scan()
if s.comments_mode == .skip_comments && t.kind == .comment {
continue
}
s.all_tokens << t
if t.kind == .eof || s.should_abort {
break
if !(is_skip_comments && t.kind == .comment) {
s.all_tokens << t
if t.kind == .eof || s.should_abort {
break
}
}
}
}
Expand Down

0 comments on commit b76d05d

Please sign in to comment.