1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: smarter if condition wrapping (#8201)

This commit is contained in:
Lukas Neubert
2021-01-23 09:33:22 +01:00
committed by GitHub
parent 9812230847
commit 8b61891348
65 changed files with 686 additions and 811 deletions

View File

@ -118,9 +118,9 @@ fn (mut ws Client) read_handshake_str() ?string {
}
msg[total_bytes_read] = buffer[0]
total_bytes_read++
if total_bytes_read > 5 && msg[total_bytes_read - 1] == `\n` && msg[total_bytes_read -
2] == `\r` && msg[total_bytes_read - 3] == `\n` && msg[total_bytes_read - 4] == `\r`
{
if total_bytes_read > 5 && msg[total_bytes_read - 1] == `\n`
&& msg[total_bytes_read - 2] == `\r` && msg[total_bytes_read - 3] == `\n`
&& msg[total_bytes_read - 4] == `\r` {
break
}
}

View File

@ -42,9 +42,8 @@ pub fn (mut ws Client) validate_frame(frame &Frame) ? {
ws.close(1002, 'rsv cannot be other than 0, not negotiated')
return error('rsv cannot be other than 0, not negotiated')
}
if (int(frame.opcode) >= 3 && int(frame.opcode) <= 7) ||
(int(frame.opcode) >= 11 && int(frame.opcode) <= 15)
{
if (int(frame.opcode) >= 3 && int(frame.opcode) <= 7)
|| (int(frame.opcode) >= 11 && int(frame.opcode) <= 15) {
ws.close(1002, 'use of reserved opcode') ?
return error('use of reserved opcode')
}

View File

@ -232,7 +232,11 @@ pub fn (mut ws Client) write_ptr(bytes byteptr, payload_len int, code OPCode) ?
// todo: send error here later
return error('trying to write on a closed socket!')
}
mut header_len := 2 + if payload_len > 125 { 2 } else { 0 } + if payload_len > 0xffff { 6 } else { 0 }
mut header_len := 2 + if payload_len > 125 { 2 } else { 0 } + if payload_len > 0xffff {
6
} else {
0
}
if !ws.is_server {
header_len += 4
}