From ffe9a6f72d7e8bfa54461c2b1ca35f0342e61c81 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Fri, 3 Sep 2021 08:22:37 -0700 Subject: [PATCH] Minor style fixes (early returns) (#1792) --- examples/2048/2048/input.go | 9 ++++----- examples/blocks/blocks/gamepad.go | 6 ++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/2048/2048/input.go b/examples/2048/2048/input.go index 338c46bdc..3d46a10c2 100644 --- a/examples/2048/2048/input.go +++ b/examples/2048/2048/input.go @@ -114,12 +114,11 @@ func vecToDir(dx, dy int) (Dir, bool) { return DirUp, true } return DirDown, true - } else { - if dx < 0 { - return DirLeft, true - } - return DirRight, true } + if dx < 0 { + return DirLeft, true + } + return DirRight, true } // Update updates the current input states. diff --git a/examples/blocks/blocks/gamepad.go b/examples/blocks/blocks/gamepad.go index 4fed8b9d9..b2643ff0b 100644 --- a/examples/blocks/blocks/gamepad.go +++ b/examples/blocks/blocks/gamepad.go @@ -211,9 +211,8 @@ func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool { v := ebiten.GamepadAxisValue(c.gamepadID, a.id) if a.positive { return axisThreshold <= v && v <= 1.0 - } else { - return -1.0 <= v && v <= -axisThreshold } + return -1.0 <= v && v <= -axisThreshold } return false } @@ -254,9 +253,8 @@ func (c *gamepadConfig) ButtonName(b virtualGamepadButton) string { if ok { if a.positive { return fmt.Sprintf("Axis %d+", a.id) - } else { - return fmt.Sprintf("Axis %d-", a.id) } + return fmt.Sprintf("Axis %d-", a.id) } return ""