remvoe dupe in main & fix js string.builder (#2233)

pull/2234/head
joe-conigliaro 2019-10-05 18:07:10 +10:00 committed by GitHub
parent a62dec2053
commit 72ae12877e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -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
}

View File

@ -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)
}