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:
@ -8,9 +8,9 @@ import strings
|
||||
fn write_value(v Any, i int, len int, mut wr strings.Builder) {
|
||||
str := v.str()
|
||||
if v is string {
|
||||
wr.write('"$str"')
|
||||
wr.write_string('"$str"')
|
||||
} else {
|
||||
wr.write(str)
|
||||
wr.write_string(str)
|
||||
}
|
||||
if i >= len - 1 {
|
||||
return
|
||||
@ -24,7 +24,7 @@ pub fn (flds map[string]Any) str() string {
|
||||
wr.write_b(`{`)
|
||||
mut i := 0
|
||||
for k, v in flds {
|
||||
wr.write('"$k":')
|
||||
wr.write_string('"$k":')
|
||||
write_value(v, i, flds.len, mut wr)
|
||||
i++
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ ffbf ffff bf00 0000 0000 0000 0000 0000
|
||||
fn save_raw_data_as_array(buf_bin []byte, file_name string) {
|
||||
mut buf := strings.new_builder(buf_bin.len * 5)
|
||||
for x in buf_bin {
|
||||
buf.write('0x${x:02x},')
|
||||
buf.write_string('0x${x:02x},')
|
||||
}
|
||||
os.write_file_array(file_name, buf.buf) or { panic(err) }
|
||||
}
|
||||
|
@ -12,17 +12,17 @@ fn (mut ws Client) handshake() ? {
|
||||
defer {
|
||||
unsafe { sb.free() }
|
||||
}
|
||||
sb.write('GET ')
|
||||
sb.write(ws.uri.resource)
|
||||
sb.write(ws.uri.querystring)
|
||||
sb.write(' HTTP/1.1\r\nHost: ')
|
||||
sb.write(ws.uri.hostname)
|
||||
sb.write(':')
|
||||
sb.write(ws.uri.port)
|
||||
sb.write('\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n')
|
||||
sb.write('Sec-WebSocket-Key: ')
|
||||
sb.write(seckey)
|
||||
sb.write('\r\nSec-WebSocket-Version: 13\r\n\r\n')
|
||||
sb.write_string('GET ')
|
||||
sb.write_string(ws.uri.resource)
|
||||
sb.write_string(ws.uri.querystring)
|
||||
sb.write_string(' HTTP/1.1\r\nHost: ')
|
||||
sb.write_string(ws.uri.hostname)
|
||||
sb.write_string(':')
|
||||
sb.write_string(ws.uri.port)
|
||||
sb.write_string('\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n')
|
||||
sb.write_string('Sec-WebSocket-Key: ')
|
||||
sb.write_string(seckey)
|
||||
sb.write_string('\r\nSec-WebSocket-Version: 13\r\n\r\n')
|
||||
handshake := sb.str()
|
||||
defer {
|
||||
unsafe { handshake.free() }
|
||||
|
Reference in New Issue
Block a user