From d981fe6a7c5513bc4b82c3cc6080b6f0df176b39 Mon Sep 17 00:00:00 2001 From: Maximilian Seidler Date: Thu, 27 Nov 2025 17:09:00 +0100 Subject: [PATCH] remove useless lock calls --- src/animation/AnimatedVariable.cpp | 33 ++++++++---------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/animation/AnimatedVariable.cpp b/src/animation/AnimatedVariable.cpp index 4db794b..1a60ec4 100644 --- a/src/animation/AnimatedVariable.cpp +++ b/src/animation/AnimatedVariable.cpp @@ -37,28 +37,22 @@ void CBaseAnimatedVariable::disconnectFromActive() { } bool Hyprutils::Animation::CBaseAnimatedVariable::enabled() const { - if (const auto PCONFIG = m_pConfig.lock()) { - const auto PVALUES = PCONFIG->pValues.lock(); - return PVALUES ? PVALUES->internalEnabled : false; - } + if (m_pConfig && m_pConfig->pValues) + return m_pConfig->pValues->internalEnabled; return false; } const std::string& CBaseAnimatedVariable::getBezierName() const { - if (const auto PCONFIG = m_pConfig.lock()) { - const auto PVALUES = PCONFIG->pValues.lock(); - return PVALUES ? PVALUES->internalBezier : DEFAULTBEZIERNAME; - } + if (m_pConfig && m_pConfig->pValues) + return m_pConfig->pValues->internalBezier; return DEFAULTBEZIERNAME; } const std::string& CBaseAnimatedVariable::getStyle() const { - if (const auto PCONFIG = m_pConfig.lock()) { - const auto PVALUES = PCONFIG->pValues.lock(); - return PVALUES ? PVALUES->internalStyle : DEFAULTSTYLE; - } + if (m_pConfig && m_pConfig->pValues) + return m_pConfig->pValues->internalStyle; return DEFAULTSTYLE; } @@ -66,10 +60,8 @@ const std::string& CBaseAnimatedVariable::getStyle() const { float CBaseAnimatedVariable::getPercent() const { const auto DURATIONPASSED = std::chrono::duration_cast(std::chrono::steady_clock::now() - animationBegin).count(); - if (const auto PCONFIG = m_pConfig.lock()) { - const auto PVALUES = PCONFIG->pValues.lock(); - return PVALUES ? std::clamp((DURATIONPASSED / 100.f) / PVALUES->internalSpeed, 0.f, 1.f) : 1.f; - } + if (m_pConfig && m_pConfig->pValues) + return std::clamp((DURATIONPASSED / 100.f) / m_pConfig->pValues->internalSpeed, 0.f, 1.f); return 1.f; } @@ -78,14 +70,7 @@ float CBaseAnimatedVariable::getCurveValue() const { if (!m_bIsBeingAnimated || isAnimationManagerDead()) return 1.f; - std::string bezierName = ""; - if (const auto PCONFIG = m_pConfig.lock()) { - const auto PVALUES = PCONFIG->pValues.lock(); - if (PVALUES) - bezierName = PVALUES->internalBezier; - } - - const auto BEZIER = m_pAnimationManager->getBezier(bezierName); + const auto BEZIER = m_pAnimationManager->getBezier(getBezierName()); if (!BEZIER) return 1.f;