scanner: minor optimization (#4211)

pull/4214/head
yuyi 2020-04-03 14:46:54 +08:00 committed by GitHub
parent 6b9bf8cbf7
commit 5e6aa5371a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -380,10 +380,8 @@ pub fn (s mut Scanner) scan() token.Token {
}
// handle each char
c := s.text[s.pos]
mut nextc := `\0`
if s.pos + 1 < s.text.len {
nextc = s.text[s.pos + 1]
}
nextc := if s.pos + 1 < s.text.len { s.text[s.pos + 1] } else { `\0` }
// name or keyword
if is_name_char(c) {
name := s.ident_name()