mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
strings, builtin: remove strings.Builder.clear()
, fix array.clear()
not working in the JS backend (#23992)
This commit is contained in:
parent
20d7d9758b
commit
15c0e6f2bd
3 changed files with 3 additions and 12 deletions
|
@ -317,7 +317,7 @@ pub fn (mut a array) reverse_in_place() {
|
|||
|
||||
pub fn (mut a array) clear() {
|
||||
#a.val.arr.make_copy()
|
||||
#a.val.arr.arr.clear()
|
||||
#a.val.arr.arr.length = 0
|
||||
}
|
||||
|
||||
// reduce executes a given reducer function on each element of the array,
|
||||
|
|
|
@ -59,11 +59,6 @@ pub fn (mut b Builder) write_runes(runes []rune) {
|
|||
}
|
||||
}
|
||||
|
||||
// clear clears the buffer contents
|
||||
pub fn (mut b Builder) clear() {
|
||||
b = []u8{cap: b.cap}
|
||||
}
|
||||
|
||||
// write_u8 appends a single `data` byte to the accumulated buffer
|
||||
@[inline]
|
||||
pub fn (mut b Builder) write_u8(data u8) {
|
||||
|
@ -246,7 +241,7 @@ pub fn (mut b Builder) str() string {
|
|||
b << u8(0)
|
||||
bcopy := unsafe { &u8(memdup_noscan(b.data, b.len)) }
|
||||
s := unsafe { bcopy.vstring_with_len(b.len - 1) }
|
||||
b.trim(0)
|
||||
b.clear()
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,6 @@ pub fn (mut b Builder) write_byte(data u8) {
|
|||
b << data
|
||||
}
|
||||
|
||||
pub fn (mut b Builder) clear() {
|
||||
b = []u8{cap: b.cap}
|
||||
}
|
||||
|
||||
pub fn (mut b Builder) write_u8(data u8) {
|
||||
b << data
|
||||
}
|
||||
|
@ -67,7 +63,7 @@ pub fn (mut b Builder) str() string {
|
|||
|
||||
#for (const c of b.val.arr.arr)
|
||||
#s.str += String.fromCharCode(+c)
|
||||
b.trim(0)
|
||||
b.clear()
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue