mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner: preallocate space for tokens to reduce the number of allocations in the hot loop
This commit is contained in:
parent
5ecaa160a7
commit
99e71d0868
@ -560,6 +560,8 @@ pub fn (mut s Scanner) scan_all_tokens_in_buffer(mode CommentsMode) {
|
|||||||
}
|
}
|
||||||
oldmode := s.comments_mode
|
oldmode := s.comments_mode
|
||||||
s.comments_mode = mode
|
s.comments_mode = mode
|
||||||
|
// preallocate space for tokens
|
||||||
|
s.all_tokens = []token.Token{cap: s.text.len / 3}
|
||||||
s.scan_remaining_text()
|
s.scan_remaining_text()
|
||||||
s.comments_mode = oldmode
|
s.comments_mode = oldmode
|
||||||
s.tidx = 0
|
s.tidx = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user