Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDM: Minor update to use std::static_pointer_cast #7998

Merged
merged 1 commit into from Apr 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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