1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: minor optimization in call_expr (#10228)

This commit is contained in:
Lukas Neubert 2021-05-27 21:40:54 +02:00 committed by GitHub
parent df2b688337
commit 8a109b031c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -354,7 +354,7 @@ pub fn (mut f Fmt) node_str(node ast.Node) string {
ast.Expr { f.expr(node) }
else { panic('´f.node_str()´ is not implemented for ${node}.') }
}
str := f.out.after(pos).trim_space()
str := f.out.after(pos)
f.out.go_back_to(pos)
f.empty_line = was_empty_line
f.line_len = prev_line_len
@ -1616,9 +1616,6 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) {
} else {
mut name := f.short_module(node.name)
f.mark_import_as_used(name)
if node.name in f.mod2alias {
name = f.mod2alias[node.name]
}
f.write('$name')
}
}
@ -2116,7 +2113,7 @@ fn (mut f Fmt) match_branch(branch ast.MatchBranch, single_line bool) {
// normal branch
f.is_mbranch_expr = true
for j, expr in branch.exprs {
estr := f.node_str(expr)
estr := f.node_str(expr).trim_space()
if f.line_len + estr.len + 2 > fmt.max_len[5] {
f.remove_new_line({})
f.writeln('')