From 1633d9af9b42420966e2c67c28e4b6ea9b593d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 2 Jun 2023 19:31:11 +0000 Subject: [PATCH] Optimise CircularIndex count No change in memory --- src/hal/circular_buffer.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/hal/circular_buffer.h b/src/hal/circular_buffer.h index 55d9bf0..1620584 100644 --- a/src/hal/circular_buffer.h +++ b/src/hal/circular_buffer.h @@ -61,15 +61,8 @@ public: } /// @returns number of elements in the buffer - /// @@TODO better solution if it exists inline index_t count() const { - index_t i = tail; - index_t c = 0; - while (i != head) { - i = next(i); - ++c; - } - return c; + return head - tail; } protected: