From b8e9f085eb4f2737cead730593b7625a8cda77a6 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 15 Apr 2021 09:41:09 +0300 Subject: [PATCH] vfmt: cleanup StringInterLiteral.get_fspec_braces/1 --- cmd/tools/vwatch.v | 2 +- vlib/benchmark/benchmark.v | 2 +- vlib/v/ast/str.v | 11 ++++------- vlib/v/gen/c/sql.v | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cmd/tools/vwatch.v b/cmd/tools/vwatch.v index 6c212f24f1..5f273279d8 100644 --- a/cmd/tools/vwatch.v +++ b/cmd/tools/vwatch.v @@ -190,7 +190,7 @@ fn (mut context Context) kill_pgroup() { } fn (mut context Context) compilation_runner_loop() { - cmd := '"${context.vexe}" ${context.opts.join(' ')}' + cmd := '"$context.vexe" ${context.opts.join(' ')}' _ := <-context.rerun_channel for { context.elog('>> loop: v_cycles: $context.v_cycles') diff --git a/vlib/benchmark/benchmark.v b/vlib/benchmark/benchmark.v index e7cef781c9..ce8df9bd8b 100644 --- a/vlib/benchmark/benchmark.v +++ b/vlib/benchmark/benchmark.v @@ -200,7 +200,7 @@ pub fn (b &Benchmark) total_message(msg string) string { if b.nskip > 0 { tmsg += term.colorize(term.bold, term.colorize(term.yellow, '$b.nskip skipped')) + ', ' } - tmsg += '${b.ntotal} total. ${term.colorize(term.bold, 'Runtime:')} ${b.bench_timer.elapsed().microseconds() / 1000} ms.\n' + tmsg += '$b.ntotal total. ${term.colorize(term.bold, 'Runtime:')} ${b.bench_timer.elapsed().microseconds() / 1000} ms.\n' return tmsg } diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index 9b2357efe8..0c1ab9d92d 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -140,12 +140,9 @@ pub fn (lit &StringInterLiteral) get_fspec_braces(i int) (string, bool) { || (lit.fills[i] && lit.fwidths[i] >= 0) || lit.fwidths[i] != 0 || lit.precisions[i] != 987698 mut needs_braces := needs_fspec - for x in lit.exprs { - sx := x.str() - if sx.contains(r'"') || sx.contains(r"'") { - needs_braces = true - break - } + sx := lit.exprs[i].str() + if sx.contains(r'"') || sx.contains(r"'") { + needs_braces = true } if !needs_braces { if i + 1 < lit.vals.len && lit.vals[i + 1].len > 0 { @@ -484,7 +481,7 @@ pub fn (node Stmt) str() string { } fn field_to_string(f ConstField) string { - return '${f.name.trim_prefix(f.mod + '.')} = ${f.expr}' + return '${f.name.trim_prefix(f.mod + '.')} = $f.expr' } pub fn (e CompForKind) str() string { diff --git a/vlib/v/gen/c/sql.v b/vlib/v/gen/c/sql.v index 5f5366da71..641d15f84c 100644 --- a/vlib/v/gen/c/sql.v +++ b/vlib/v/gen/c/sql.v @@ -901,7 +901,7 @@ fn (mut g Gen) table_gen(node ast.SqlStmt, typ SqlType) string { for f in v { tmp << '`$f`' } - fields << '/* ${k} */UNIQUE(${tmp.join(', ')})' + fields << '/* $k */UNIQUE(${tmp.join(', ')})' } } if typ == .mysql {