mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: minor cleanup in str.v (#14882)
This commit is contained in:
parent
f2be115f7d
commit
92f441e894
@ -19,29 +19,18 @@ fn (mut g Gen) string_literal(node ast.StringLiteral) {
|
|||||||
// `sb.writeln('a='); sb.writeln(a.str())`
|
// `sb.writeln('a='); sb.writeln(a.str())`
|
||||||
fn (mut g Gen) string_inter_literal_sb_optimized(call_expr ast.CallExpr) {
|
fn (mut g Gen) string_inter_literal_sb_optimized(call_expr ast.CallExpr) {
|
||||||
node := call_expr.args[0].expr as ast.StringInterLiteral
|
node := call_expr.args[0].expr as ast.StringInterLiteral
|
||||||
// sb_name := g.cur_call_expr.left
|
|
||||||
// g.go_before_stmt(0)
|
|
||||||
g.writeln('// sb inter opt')
|
g.writeln('// sb inter opt')
|
||||||
is_nl := call_expr.name == 'writeln'
|
is_nl := call_expr.name == 'writeln'
|
||||||
// println('optimize sb $call_expr.name')
|
|
||||||
for i, val in node.vals {
|
for i, val in node.vals {
|
||||||
escaped_val := cescape_nonascii(util.smart_quote(val, false))
|
escaped_val := cescape_nonascii(util.smart_quote(val, false))
|
||||||
// if val == '' {
|
|
||||||
// break
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
g.write('strings__Builder_write_string(&')
|
g.write('strings__Builder_write_string(&')
|
||||||
g.expr(call_expr.left)
|
g.expr(call_expr.left)
|
||||||
g.write(', _SLIT("')
|
g.write(', _SLIT("')
|
||||||
g.write(escaped_val)
|
g.write(escaped_val)
|
||||||
g.writeln('"));')
|
g.writeln('"));')
|
||||||
//
|
|
||||||
if i >= node.exprs.len {
|
if i >= node.exprs.len {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// if node.expr_types.len <= i || node.exprs.len <= i {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
if is_nl && i == node.exprs.len - 1 {
|
if is_nl && i == node.exprs.len - 1 {
|
||||||
g.write('strings__Builder_writeln(&')
|
g.write('strings__Builder_writeln(&')
|
||||||
} else {
|
} else {
|
||||||
@ -59,7 +48,6 @@ fn (mut g Gen) string_inter_literal_sb_optimized(call_expr ast.CallExpr) {
|
|||||||
g.writeln('));')
|
g.writeln('));')
|
||||||
}
|
}
|
||||||
g.writeln('')
|
g.writeln('')
|
||||||
// println(node.vals)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +124,6 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) {
|
|||||||
g.write(')')
|
g.write(')')
|
||||||
if is_ptr && !is_var_mut {
|
if is_ptr && !is_var_mut {
|
||||||
g.write('}}}))')
|
g.write('}}}))')
|
||||||
// g.write(')')
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
str_fn_name := g.get_str_fn(typ)
|
str_fn_name := g.get_str_fn(typ)
|
||||||
|
Loading…
Reference in New Issue
Block a user