mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
remvoe dupe in main & fix js string.builder (#2233)
This commit is contained in:
parent
a62dec2053
commit
72ae12877e
@ -557,9 +557,6 @@ fn (v &V) v_files_from_dir(dir string) []string {
|
||||
if file.ends_with('_mac.v') && v.os != .mac {
|
||||
continue
|
||||
}
|
||||
if file.ends_with('_js.v') && v.os != .js {
|
||||
continue
|
||||
}
|
||||
if file.ends_with('_nix.v') && (v.os == .windows || v.os == .msvc) {
|
||||
continue
|
||||
}
|
||||
|
@ -5,27 +5,39 @@
|
||||
module strings
|
||||
|
||||
struct Builder {
|
||||
mut:
|
||||
buf []byte
|
||||
pub:
|
||||
len int
|
||||
}
|
||||
|
||||
pub fn new_builder(initial_size int) Builder {
|
||||
return Builder {
|
||||
buf: _make(0, initial_size, sizeof(byte))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (b mut Builder) write(s string) {
|
||||
b.buf._push_many(s.str, s.len)
|
||||
//b.buf << []byte(s) // TODO
|
||||
b.len += s.len
|
||||
}
|
||||
|
||||
pub fn (b mut Builder) writeln(s string) {
|
||||
b.buf._push_many(s.str, s.len)
|
||||
//b.buf << []byte(s) // TODO
|
||||
b.buf << `\n`
|
||||
b.len += s.len + 1
|
||||
}
|
||||
|
||||
pub fn (b Builder) str() string {
|
||||
return ''
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user