all: remove redundant parentheses in `if` statements

pull/4155/head
Alexey 2020-03-29 11:08:42 +03:00 committed by GitHub
parent e09447d011
commit a333ac1888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 16 additions and 18 deletions

View File

@ -148,7 +148,7 @@ ${flag.SPACE}to script it/run it in a restrictive vps/docker.
context.show_help = fp.bool('help', `h`, false, 'Show this help screen.') context.show_help = fp.bool('help', `h`, false, 'Show this help screen.')
context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.') context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.')
if (context.show_help) { if context.show_help {
println(fp.usage()) println(fp.usage())
exit(0) exit(0)
} }

View File

@ -72,7 +72,7 @@ fn main() {
context.show_help = fp.bool('help', `h`, false, 'Show this help screen.') context.show_help = fp.bool('help', `h`, false, 'Show this help screen.')
context.module_name = fp.string('module', `m`, 'binary', 'Name of the generated module.\n') context.module_name = fp.string('module', `m`, 'binary', 'Name of the generated module.\n')
context.prefix = fp.string('prefix', `p`, '', 'A prefix put before each resource name.\n') context.prefix = fp.string('prefix', `p`, '', 'A prefix put before each resource name.\n')
if (context.show_help) { if context.show_help {
println(fp.usage()) println(fp.usage())
exit(0) exit(0)
} }

View File

@ -469,7 +469,7 @@ fn get_module_meta_info(name string) ?Mod {
errors << 'Skipping module "$name", since its information is not in json format.' errors << 'Skipping module "$name", since its information is not in json format.'
continue continue
} }
if ('' == mod.url || '' == mod.name) { if '' == mod.url || '' == mod.name {
errors << 'Skipping module "$name", since it is missing name or url information.' errors << 'Skipping module "$name", since it is missing name or url information.'
continue continue
} }

View File

@ -269,7 +269,7 @@ fn (sdlc mut SdlContext) set_sdl_context(w int, h int, title string) {
} }
flags := C.IMG_INIT_PNG flags := C.IMG_INIT_PNG
imgres := img.img_init(flags) imgres := img.img_init(flags)
if ((imgres & flags) != flags) { if (imgres & flags) != flags {
println('error initializing image library.') println('error initializing image library.')
} }
println('opening logo $VLogo') println('opening logo $VLogo')

View File

@ -509,7 +509,7 @@ pub fn (instance BitField) rotate(offset int) BitField {
// removing extra rotations // removing extra rotations
mut offset_internal := offset % size mut offset_internal := offset % size
if (offset_internal == 0) { if offset_internal == 0 {
// nothing to shift // nothing to shift
return instance return instance
} }

View File

@ -101,7 +101,7 @@ pub fn i64_tos(buf byteptr, len int, n0 i64, base int) string {
n /= base n /= base
if n < 1 {break} if n < 1 {break}
} }
if (neg) { if neg {
if i < 0 { panic ("buffer to small") } if i < 0 { panic ("buffer to small") }
b[i--] = 45 b[i--] = 45
} }
@ -132,4 +132,3 @@ pub fn (a string) clone() string {
b[a.len] = `\0` b[a.len] = `\0`
return b return b
} }

View File

@ -237,7 +237,7 @@ fn (cb mut Clipboard) start_listener(){
mut to_be_requested := Atom(0) mut to_be_requested := Atom(0)
for { for {
XNextEvent(cb.display, &event) XNextEvent(cb.display, &event)
if (event.@type == 0) { if event.@type == 0 {
println("error") println("error")
continue continue
} }

View File

@ -34,7 +34,7 @@ pub fn resource_path() string {
main_bundle := C.CFBundleGetMainBundle() main_bundle := C.CFBundleGetMainBundle()
resource_dir_url := C.CFBundleCopyResourcesDirectoryURL(main_bundle) resource_dir_url := C.CFBundleCopyResourcesDirectoryURL(main_bundle)
if (isnil(resource_dir_url)) { if isnil(resource_dir_url) {
panic('CFBundleCopyResourcesDirectoryURL failed') panic('CFBundleCopyResourcesDirectoryURL failed')
} }
buffer_size := 4096 buffer_size := 4096
@ -48,4 +48,3 @@ pub fn resource_path() string {
C.CFRelease(resource_dir_url) C.CFRelease(resource_dir_url)
return result return result
} }

View File

@ -64,7 +64,7 @@ pub fn (conn Connection) select_db(dbname string) ?bool {
pub fn (conn Connection) change_user(username, password, dbname string) ?bool { pub fn (conn Connection) change_user(username, password, dbname string) ?bool {
mut ret := true mut ret := true
if (dbname != '') { if dbname != '' {
ret = mysql_change_user(conn.conn, username.str, password.str, dbname.str) ret = mysql_change_user(conn.conn, username.str, password.str, dbname.str)
} else { } else {
ret = mysql_change_user(conn.conn, username.str, password.str, 0) ret = mysql_change_user(conn.conn, username.str, password.str, 0)

View File

@ -121,11 +121,11 @@ fn rw_callback(loop *C.picoev_loop, fd, events int, cb_arg voidptr) {
buf := (p.buf + fd * MAX_READ) buf := (p.buf + fd * MAX_READ)
idx := p.idx[fd] idx := p.idx[fd]
mut r := myread(fd, buf, MAX_READ, idx) mut r := myread(fd, buf, MAX_READ, idx)
if (r == 0) { if r == 0 {
close_conn(loop, fd) close_conn(loop, fd)
p.idx[fd] = 0 p.idx[fd] = 0
return return
} else if (r == -1) { } else if r == -1 {
if errno == C.EAGAIN || errno == C.EWOULDBLOCK { if errno == C.EAGAIN || errno == C.EWOULDBLOCK {
// //
} else { } else {

View File

@ -62,7 +62,7 @@ pub fn (r mut Readline) enable_raw_mode() {
// Enable the raw mode of the terminal // Enable the raw mode of the terminal
// Does not catch the SIGUSER (CTRL+C) Signal // Does not catch the SIGUSER (CTRL+C) Signal
pub fn (r mut Readline) enable_raw_mode_nosig() { pub fn (r mut Readline) enable_raw_mode_nosig() {
if ( C.tcgetattr(0, &r.orig_termios) == -1 ) { if C.tcgetattr(0, &r.orig_termios) == -1 {
r.is_tty = false r.is_tty = false
r.is_raw = false r.is_raw = false
return return
@ -319,7 +319,7 @@ fn calculate_screen_position(x_in int, y_in int, screen_columns int, char_count
out[0] = x out[0] = x
out[1] = y out[1] = y
for chars_remaining := char_count; chars_remaining > 0; { for chars_remaining := char_count; chars_remaining > 0; {
chars_this_row := if ( (x + chars_remaining) < screen_columns) { chars_remaining } else { screen_columns - x } chars_this_row := if (x + chars_remaining) < screen_columns { chars_remaining } else { screen_columns - x }
out[0] = x + chars_this_row out[0] = x + chars_this_row
out[1] = y out[1] = y
chars_remaining -= chars_this_row chars_remaining -= chars_this_row

View File

@ -131,7 +131,7 @@ pub fn atof_quick(s string) f64 {
} }
else { else {
if exp > neg_exp.len { if exp > neg_exp.len {
if (sign > 0) { if sign > 0 {
f.u = DOUBLE_PLUS_ZERO f.u = DOUBLE_PLUS_ZERO
} }
else { else {

View File

@ -498,7 +498,7 @@ fn (f mut Fmt) expr(node ast.Expr) {
else { else {
f.write('else') f.write('else')
} }
if (branch.stmts.len == 0) { if branch.stmts.len == 0 {
f.writeln(' {}') f.writeln(' {}')
} }
else { else {