From 91956d152df92104cabf226f0ba0bda5b8d77185 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Tue, 9 Jan 2024 17:05:11 -0700 Subject: [PATCH] Remove unnecessary scope --- src/SFML/Graphics/RenderTarget.cpp | 46 ++++++++++++++---------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index b3c183e07..dec7c6a60 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -480,39 +480,37 @@ bool RenderTarget::isSrgb() const bool RenderTarget::setActive(bool active) { // Mark this RenderTarget as active or no longer active in the tracking map + const std::lock_guard lock(RenderTargetImpl::getMutex()); + + const std::uint64_t contextId = Context::getActiveContextId(); + + using RenderTargetImpl::getContextRenderTargetMap; + auto& contextRenderTargetMap = getContextRenderTargetMap(); + const auto it = contextRenderTargetMap.find(contextId); + + if (active) { - const std::lock_guard lock(RenderTargetImpl::getMutex()); - - const std::uint64_t contextId = Context::getActiveContextId(); - - using RenderTargetImpl::getContextRenderTargetMap; - auto& contextRenderTargetMap = getContextRenderTargetMap(); - const auto it = contextRenderTargetMap.find(contextId); - - if (active) + if (it == contextRenderTargetMap.end()) { - if (it == contextRenderTargetMap.end()) - { - contextRenderTargetMap[contextId] = m_id; + contextRenderTargetMap[contextId] = m_id; - m_cache.glStatesSet = false; - m_cache.enable = false; - } - else if (it->second != m_id) - { - it->second = m_id; - - m_cache.enable = false; - } + m_cache.glStatesSet = false; + m_cache.enable = false; } - else + else if (it->second != m_id) { - if (it != contextRenderTargetMap.end()) - contextRenderTargetMap.erase(it); + it->second = m_id; m_cache.enable = false; } } + else + { + if (it != contextRenderTargetMap.end()) + contextRenderTargetMap.erase(it); + + m_cache.enable = false; + } return true; }