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

all: add strings.Builder.write_string and use write_string instead of write (#8892)

This commit is contained in:
zakuro
2021-02-22 20:18:11 +09:00
committed by GitHub
parent 36a6bc270c
commit f54c1a5cc2
34 changed files with 402 additions and 397 deletions

View File

@ -142,7 +142,7 @@ fn pretty_description(s string, indent_len int) string {
mut acc := strings.new_builder(((s.len / chars_per_line) + 1) * (width + 1))
for k, line in s.split('\n') {
if k != 0 {
acc.write('\n$indent')
acc.write_string('\n$indent')
}
mut i := chars_per_line - 2
mut j := 0
@ -152,16 +152,16 @@ fn pretty_description(s string, indent_len int) string {
}
// indent was already done the first iteration
if j != 0 {
acc.write(indent)
acc.write_string(indent)
}
acc.writeln(line[j..i].trim_space())
j = i
}
// We need this even though it should never happen
if j != 0 {
acc.write(indent)
acc.write_string(indent)
}
acc.write(line[j..].trim_space())
acc.write_string(line[j..].trim_space())
}
return acc.str()
}