From d36667c84ab59bd54d544d277766ddc94a61a0ef Mon Sep 17 00:00:00 2001 From: muramura Date: Sat, 23 Sep 2023 08:36:10 +0900 Subject: [PATCH] Copter: Change to ternary operator --- ArduCopter/mode_zigzag.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/ArduCopter/mode_zigzag.cpp b/ArduCopter/mode_zigzag.cpp index 1bb82aaadb..2952158ec6 100644 --- a/ArduCopter/mode_zigzag.cpp +++ b/ArduCopter/mode_zigzag.cpp @@ -585,27 +585,15 @@ void ModeZigZag::spray(bool b) uint32_t ModeZigZag::wp_distance() const { - if (is_auto) { - return wp_nav->get_wp_distance_to_destination(); - } else { - return 0; - } + return is_auto ? wp_nav->get_wp_distance_to_destination() : 0; } int32_t ModeZigZag::wp_bearing() const { - if (is_auto) { - return wp_nav->get_wp_bearing_to_destination(); - } else { - return 0; - } + return is_auto ? wp_nav->get_wp_bearing_to_destination() : 0; } float ModeZigZag::crosstrack_error() const { - if (is_auto) { - return wp_nav->crosstrack_error(); - } else { - return 0; - } + return is_auto ? wp_nav->crosstrack_error() : 0; } #endif // MODE_ZIGZAG_ENABLED == ENABLED