mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix a bug in strings.Builder and wrap up vfmt
This commit is contained in:
@@ -13,17 +13,23 @@ pub:
|
||||
|
||||
pub fn new_builder(initial_size int) Builder {
|
||||
return Builder {
|
||||
buf: make(0, initial_size, sizeof(byte))
|
||||
buf: make(0, initial_size, 1)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (b mut Builder) write(s string) {
|
||||
b.buf.push_many(s.str, s.len)
|
||||
//for c in s {
|
||||
//b.buf << c
|
||||
//}
|
||||
//b.buf << []byte(s) // TODO
|
||||
b.len += s.len
|
||||
}
|
||||
|
||||
pub fn (b mut Builder) writeln(s string) {
|
||||
//for c in s {
|
||||
//b.buf << c
|
||||
//}
|
||||
b.buf.push_many(s.str, s.len)
|
||||
//b.buf << []byte(s) // TODO
|
||||
b.buf << `\n`
|
||||
@@ -34,10 +40,6 @@ pub fn (b Builder) str() string {
|
||||
return string(b.buf, b.len)
|
||||
}
|
||||
|
||||
pub fn (b mut Builder) cut(n int) {
|
||||
b.len -= n
|
||||
}
|
||||
|
||||
pub fn (b mut Builder) free() {
|
||||
//free(b.buf.data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user