From a89e06a54e51e5a5016ab6b2135b0794a85e9468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 20 Aug 2023 19:39:38 +0000 Subject: [PATCH] optimisation: Timer constructor can be constexpr Change in memory: Flash: -206 bytes SRAM: -16 bytes --- Firmware/Timer.cpp | 11 ----------- Firmware/Timer.h | 5 ++++- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Firmware/Timer.cpp b/Firmware/Timer.cpp index d0a552b0a..b3ee423b2 100644 --- a/Firmware/Timer.cpp +++ b/Firmware/Timer.cpp @@ -6,17 +6,6 @@ #include "Timer.h" #include "system_timer.h" -/** - * @brief construct Timer - * - * It is guaranteed, that construction is equivalent with zeroing all members. - * This property can be exploited in menu_data. - */ -template -Timer::Timer() : m_isRunning(false), m_started() -{ -} - /** * @brief Start timer */ diff --git a/Firmware/Timer.h b/Firmware/Timer.h index 9cb18a304..9880764d6 100644 --- a/Firmware/Timer.h +++ b/Firmware/Timer.h @@ -17,7 +17,10 @@ template class Timer { public: - Timer(); + inline constexpr Timer() + : m_isRunning(false) + , m_started(0) {}; + void start(); void stop(){m_isRunning = false;} bool running()const {return m_isRunning;}