From 5498b9ae675e8fa651407979bd29ef2780a3bbf7 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Mon, 6 Aug 2018 14:04:02 +1200 Subject: [PATCH] Remove intermediate variable (-48 bytes) --- Core.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Core.cpp b/Core.cpp index faf9115..591c175 100644 --- a/Core.cpp +++ b/Core.cpp @@ -95,9 +95,10 @@ namespace core { } bool updateSleepTime() { - uint8_t velocity = gps::getVelocity(); - uint16_t result = mapSleepTime(velocity); bool goingLongSleep = false; + uint8_t velocity = gps::getVelocity(); + + sleepTime = mapSleepTime(velocity); if (velocity < SLEEP_TIMING_MIN_MOVING_VELOCITY) { float distance = gps::getDistanceFromPrevious(); //did we missed positions because we were sleeping ? @@ -105,15 +106,13 @@ namespace core { else stoppedInARow = min(stoppedInARow + 1, SLEEP_DEFAULT_STOPPED_THRESHOLD + 1); //avoid overflow on REALLY long stops if (stoppedInARow < SLEEP_DEFAULT_STOPPED_THRESHOLD) { - result = SLEEP_DEFAULT_PAUSING_TIME_SECONDS; + sleepTime = SLEEP_DEFAULT_PAUSING_TIME_SECONDS; } else if (stoppedInARow == SLEEP_DEFAULT_STOPPED_THRESHOLD) goingLongSleep = true; } else stoppedInARow = 0; - sleepTime = result; NOTICE_FORMAT("updateSleepTime", "%dkmh => %d seconds", velocity, sleepTime); - return goingLongSleep; }