mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner: minor optimization (#15313)
This commit is contained in:
parent
dab8159b56
commit
7546d1450c
@ -114,6 +114,7 @@ pub fn new_scanner_file(file_path string, comments_mode CommentsMode, pref &pref
|
|||||||
mut s := &Scanner{
|
mut s := &Scanner{
|
||||||
pref: pref
|
pref: pref
|
||||||
text: raw_text
|
text: raw_text
|
||||||
|
all_tokens: []token.Token{cap: raw_text.len / 3}
|
||||||
is_print_line_on_error: true
|
is_print_line_on_error: true
|
||||||
is_print_colored_error: true
|
is_print_colored_error: true
|
||||||
is_print_rel_paths_on_error: true
|
is_print_rel_paths_on_error: true
|
||||||
@ -131,6 +132,7 @@ pub fn new_scanner(text string, comments_mode CommentsMode, pref &pref.Preferenc
|
|||||||
mut s := &Scanner{
|
mut s := &Scanner{
|
||||||
pref: pref
|
pref: pref
|
||||||
text: text
|
text: text
|
||||||
|
all_tokens: []token.Token{cap: text.len / 3}
|
||||||
is_print_line_on_error: true
|
is_print_line_on_error: true
|
||||||
is_print_colored_error: true
|
is_print_colored_error: true
|
||||||
is_print_rel_paths_on_error: true
|
is_print_rel_paths_on_error: true
|
||||||
@ -560,8 +562,6 @@ pub fn (mut s Scanner) scan_all_tokens_in_buffer() {
|
|||||||
util.timing_measure_cumulative('SCAN')
|
util.timing_measure_cumulative('SCAN')
|
||||||
timers.measure_resume('PARSE')
|
timers.measure_resume('PARSE')
|
||||||
}
|
}
|
||||||
// preallocate space for tokens
|
|
||||||
s.all_tokens = []token.Token{cap: s.text.len / 3}
|
|
||||||
s.scan_remaining_text()
|
s.scan_remaining_text()
|
||||||
s.tidx = 0
|
s.tidx = 0
|
||||||
$if debugscanner ? {
|
$if debugscanner ? {
|
||||||
|
Loading…
Reference in New Issue
Block a user