From c19a9dc8474e57bc8e4c8e237da8d8f4298df686 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 9 Apr 2020 19:05:36 +0300 Subject: [PATCH] idm: Minor update to use std::static_pointer_cast --- rpcs3/Emu/IdManager.h | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 3463ef6fc91f..764ea8eb3b93 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -423,7 +423,7 @@ class idm return nullptr; } - return {found->second, static_cast(found->second.get())}; + return std::static_pointer_cast(found->second); } // Get the object @@ -439,7 +439,7 @@ class idm return nullptr; } - return {found->second, static_cast(found->second.get())}; + return std::static_pointer_cast(found->second); } // Get the object, access object under reader lock @@ -568,21 +568,17 @@ class idm template static inline std::shared_ptr withdraw(u32 id) { - std::shared_ptr ptr; + std::shared_ptr ptr; { std::lock_guard lock(id_manager::g_mutex); if (const auto found = find_id(id)) { - ptr = std::move(found->second); - } - else - { - return nullptr; + ptr = std::static_pointer_cast(std::move(found->second)); } } - return {ptr, static_cast(ptr.get())}; + return ptr; } // Remove the ID after accessing the object under writer lock, return the object and propagate return value @@ -598,8 +594,7 @@ class idm if constexpr (std::is_void_v) { func(*_ptr); - std::shared_ptr ptr = std::move(found->second); - return {ptr, static_cast(ptr.get())}; + return std::static_pointer_cast(std::move(found->second)); } else { @@ -611,8 +606,7 @@ class idm return {{found->second, _ptr}, std::move(ret)}; } - std::shared_ptr ptr = std::move(found->second); - return {{ptr, static_cast(ptr.get())}, std::move(ret)}; + return {std::static_pointer_cast(std::move(found->second)), std::move(ret)}; } }