Skip to content

Commit

Permalink
idm: Minor update to use std::static_pointer_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Apr 9, 2020
1 parent df20410 commit c19a9dc
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions rpcs3/Emu/IdManager.h
Expand Up @@ -423,7 +423,7 @@ class idm
return nullptr;
}

return {found->second, static_cast<Get*>(found->second.get())};
return std::static_pointer_cast<Get>(found->second);
}

// Get the object
Expand All @@ -439,7 +439,7 @@ class idm
return nullptr;
}

return {found->second, static_cast<Get*>(found->second.get())};
return std::static_pointer_cast<Get>(found->second);
}

// Get the object, access object under reader lock
Expand Down Expand Up @@ -568,21 +568,17 @@ class idm
template <typename T, typename Get = T>
static inline std::shared_ptr<Get> withdraw(u32 id)
{
std::shared_ptr<void> ptr;
std::shared_ptr<Get> ptr;
{
std::lock_guard lock(id_manager::g_mutex);

if (const auto found = find_id<T, Get>(id))
{
ptr = std::move(found->second);
}
else
{
return nullptr;
ptr = std::static_pointer_cast<Get>(std::move(found->second));
}
}

return {ptr, static_cast<Get*>(ptr.get())};
return ptr;
}

// Remove the ID after accessing the object under writer lock, return the object and propagate return value
Expand All @@ -598,8 +594,7 @@ class idm
if constexpr (std::is_void_v<FRT>)
{
func(*_ptr);
std::shared_ptr<void> ptr = std::move(found->second);
return {ptr, static_cast<Get*>(ptr.get())};
return std::static_pointer_cast<Get>(std::move(found->second));
}
else
{
Expand All @@ -611,8 +606,7 @@ class idm
return {{found->second, _ptr}, std::move(ret)};
}

std::shared_ptr<void> ptr = std::move(found->second);
return {{ptr, static_cast<Get*>(ptr.get())}, std::move(ret)};
return {std::static_pointer_cast<Get>(std::move(found->second)), std::move(ret)};
}
}

Expand Down

0 comments on commit c19a9dc

Please sign in to comment.