From 0c4f8445dae00cf3fa225c561ad355fd41b128f0 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Wed, 26 Aug 2026 22:46:50 +0200 Subject: [PATCH] [Log] Code optimization --- src/src/DataStructs/LogBuffer.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/src/DataStructs/LogBuffer.cpp b/src/src/DataStructs/LogBuffer.cpp index d07b00b32..f96b0b8ad 100644 --- a/src/src/DataStructs/LogBuffer.cpp +++ b/src/src/DataStructs/LogBuffer.cpp @@ -36,24 +36,21 @@ bool LogBuffer::getNext(LogDestination logDestination, uint32_t& timestamp, Stri bool LogBuffer::hasMessages(LogDestination logDestination) { - uint32_t res{}; - - if (logDestination >= NR_LOG_TO_DESTINATIONS) { return res; } + if (logDestination >= NR_LOG_TO_DESTINATIONS) { return false; } clearExpiredEntries(); // Cleanup the old stuff first uint32_t pos = cache_iterator_pos[logDestination]; - for (; pos < LogEntries.size() && !res; ++pos) { + for (; pos < LogEntries.size(); ++pos) { if (LogEntries[pos].validForSubscriber(logDestination)) { - ++res; + cache_iterator_pos[logDestination] = pos; + return true; } } - if (!res) { - lastReadTimeStamp[logDestination] = millis(); // Reset if we aren't going to fetch a next message - } - return !!res; + lastReadTimeStamp[logDestination] = millis(); // Reset if we aren't going to fetch a next message + return false; } bool LogBuffer::logActiveRead(LogDestination logDestination) {