From 358e8ede1c3ed6720b8674e69601eff7f4634ad3 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 17 Mar 2019 02:59:36 +0100 Subject: [PATCH] Remove Time::getApproximateMillisecondCounter from water Signed-off-by: falkTX --- source/modules/water/misc/Time.cpp | 10 ++++------ source/modules/water/misc/Time.h | 13 ------------- source/modules/water/text/StringPool.cpp | 4 ++-- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/source/modules/water/misc/Time.cpp b/source/modules/water/misc/Time.cpp index cd1e73c87..a670549b3 100644 --- a/source/modules/water/misc/Time.cpp +++ b/source/modules/water/misc/Time.cpp @@ -81,7 +81,11 @@ static uint32 water_millisecondsSinceStartup() noexcept return (uint32) timeGetTime(); #else timespec t; +# ifdef CLOCK_MONOTONIC_RAW + clock_gettime (CLOCK_MONOTONIC_RAW, &t); +# else clock_gettime (CLOCK_MONOTONIC, &t); +# endif return (uint32) (t.tv_sec * 1000 + t.tv_nsec / 1000000); #endif @@ -146,10 +150,4 @@ uint32 Time::getMillisecondCounter() noexcept return now; } -uint32 Time::getApproximateMillisecondCounter() noexcept -{ - const uint32 t = TimeHelpers::lastMSCounterValue.get(); - return t == 0 ? getMillisecondCounter() : t; -} - } diff --git a/source/modules/water/misc/Time.h b/source/modules/water/misc/Time.h index 0749898f7..fb66bd891 100644 --- a/source/modules/water/misc/Time.h +++ b/source/modules/water/misc/Time.h @@ -103,22 +103,9 @@ public: Being a 32-bit return value, it will of course wrap back to 0 after 2^32 seconds of uptime, so be careful to take that into account. If you need a 64-bit time, you can use currentTimeMillis() instead. - - @see getApproximateMillisecondCounter */ static uint32 getMillisecondCounter() noexcept; - /** Less-accurate but faster version of getMillisecondCounter(). - - This will return the last value that getMillisecondCounter() returned, so doesn't - need to make a system call, but is less accurate - it shouldn't be more than - 100ms away from the correct time, though, so is still accurate enough for a - lot of purposes. - - @see getMillisecondCounter - */ - static uint32 getApproximateMillisecondCounter() noexcept; - private: //============================================================================== int64 millisSinceEpoch; diff --git a/source/modules/water/text/StringPool.cpp b/source/modules/water/text/StringPool.cpp index a63b35c98..e92db5d5b 100644 --- a/source/modules/water/text/StringPool.cpp +++ b/source/modules/water/text/StringPool.cpp @@ -146,7 +146,7 @@ String StringPool::getPooledString (const String& newString) void StringPool::garbageCollectIfNeeded() { if (strings.size() > minNumberOfStringsForGarbageCollection - && Time::getApproximateMillisecondCounter() > lastGarbageCollectionTime + garbageCollectionInterval) + && Time::getMillisecondCounter() > lastGarbageCollectionTime + garbageCollectionInterval) garbageCollect(); } @@ -158,7 +158,7 @@ void StringPool::garbageCollect() if (strings.getReference(i).getReferenceCount() == 1) strings.remove (i); - lastGarbageCollectionTime = Time::getApproximateMillisecondCounter(); + lastGarbageCollectionTime = Time::getMillisecondCounter(); } StringPool& StringPool::getGlobalPool() noexcept