From 0f326c1413ec5d835a6a5f1f4ef731506f23574e Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Wed, 18 Dec 2024 16:32:14 -0600 Subject: [PATCH] simplifications no point in calling `owns_lock` twice --- library/include/Core.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/include/Core.h b/library/include/Core.h index c0817ee4f4..dc7c414605 100644 --- a/library/include/Core.h +++ b/library/include/Core.h @@ -397,7 +397,7 @@ namespace DFHack } ~CoreSuspenderBase() { - if (owns_lock()) unlock(); + unlock(); } protected: @@ -448,13 +448,14 @@ namespace DFHack lock(); } + // note that this is needed so the destructor will call CoreSuspender::unlock instead of CoreSuspenderBase::unlock ~CoreSuspender() { - if (owns_lock()) unlock(); + unlock(); } protected: // deferred locking is not part of CoreSuspender's public API - // these constructors are onmly for use in derived classes, + // these constructors are only for use in derived classes, // specifically ConditionalCoreSuspender CoreSuspender(std::defer_lock_t d) : CoreSuspender{ Core::getInstance(),d } {} CoreSuspender(Core& core, std::defer_lock_t d) : CoreSuspenderBase{ core } {}