mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: -autofree fixes for []string{} having literals, comming from defailt string stuct field values
This commit is contained in:
@@ -62,10 +62,13 @@ fn new_aints(ovals []int, extreme_mins int, extreme_maxs int) Aints {
|
||||
mut imin := math.max_i32
|
||||
mut imax := -math.max_i32
|
||||
// discard the extremes:
|
||||
mut vals := ovals.clone()
|
||||
mut vals := []int{}
|
||||
for x in ovals {
|
||||
vals << x
|
||||
}
|
||||
vals.sort()
|
||||
if vals.len > extreme_mins + extreme_maxs {
|
||||
vals = vals[extreme_mins..vals.len - extreme_maxs]
|
||||
vals = vals[extreme_mins..vals.len - extreme_maxs].clone()
|
||||
} else {
|
||||
vals = []
|
||||
}
|
||||
@@ -152,7 +155,10 @@ fn (mut context Context) parse_options() {
|
||||
exit(1)
|
||||
}
|
||||
context.commands = context.expand_all_commands(commands)
|
||||
context.results = []CmdResult{len: context.commands.len, init: CmdResult{}}
|
||||
context.results = []CmdResult{len: context.commands.len, cap: 100, init: CmdResult{
|
||||
outputs: []string{cap: 1000}
|
||||
timings: []int{cap: 1000}
|
||||
}}
|
||||
if context.use_newline {
|
||||
context.cline = '\n'
|
||||
context.cgoback = '\n'
|
||||
@@ -170,7 +176,8 @@ fn (mut context Context) expand_all_commands(commands []string) []string {
|
||||
mut all_commands := []string{}
|
||||
for cmd in commands {
|
||||
maincmd := context.cmd_template.replace('{T}', cmd)
|
||||
mut substituted_commands := [maincmd]
|
||||
mut substituted_commands := []string{}
|
||||
substituted_commands << maincmd
|
||||
for paramk, paramlist in context.cmd_params {
|
||||
for paramv in paramlist {
|
||||
mut new_substituted_commands := []string{}
|
||||
@@ -178,10 +185,14 @@ fn (mut context Context) expand_all_commands(commands []string) []string {
|
||||
scmd := cscmd.replace(paramk, paramv)
|
||||
new_substituted_commands << scmd
|
||||
}
|
||||
substituted_commands << new_substituted_commands
|
||||
for sc in new_substituted_commands {
|
||||
substituted_commands << sc
|
||||
}
|
||||
}
|
||||
}
|
||||
all_commands << substituted_commands
|
||||
for sc in substituted_commands {
|
||||
all_commands << sc
|
||||
}
|
||||
}
|
||||
mut unique := map[string]int{}
|
||||
for x in all_commands {
|
||||
@@ -228,8 +239,10 @@ fn (mut context Context) run() {
|
||||
eprintln('${i:10} non 0 exit code for cmd: $cmd')
|
||||
continue
|
||||
}
|
||||
context.results[icmd].outputs << res.output.trim_right('\r\n').replace('\r\n',
|
||||
'\n').split('\n')
|
||||
trimed_output := res.output.trim_right('\r\n')
|
||||
trimed_normalized := trimed_output.replace('\r\n', '\n')
|
||||
lines := trimed_normalized.split('\n')
|
||||
context.results[icmd].outputs << lines
|
||||
context.results[icmd].timings << duration
|
||||
sum += duration
|
||||
runs++
|
||||
@@ -296,10 +309,12 @@ fn (mut context Context) show_diff_summary() {
|
||||
println('Summary (commands are ordered by ascending mean time), after $context.series series of $context.count repetitions:')
|
||||
base := context.results[0].atiming.average
|
||||
mut first_cmd_percentage := f64(100.0)
|
||||
mut first_marker := ''
|
||||
for i, r in context.results {
|
||||
first_marker = ' '
|
||||
cpercent := (r.atiming.average / base) * 100 - 100
|
||||
first_marker := if r.icmd == 0 { util.bold('>') } else { ' ' }
|
||||
if r.icmd == 0 {
|
||||
first_marker = util.bold('>')
|
||||
first_cmd_percentage = cpercent
|
||||
}
|
||||
println(' $first_marker${(i + 1):3} | ${cpercent:5.1f}% slower | ${r.cmd:-57s} | $r.atiming')
|
||||
|
||||
Reference in New Issue
Block a user