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

Common/PointerWrap: Remove DoPOD #11124

Merged
merged 2 commits into from Oct 6, 2022

Conversation

Pokechu22
Copy link
Contributor

This was added in 385d8e2, but became somewhat redundant with Do in 4c7bbd9, and completely redundant now that std::is_trivially_copyable_v is well-supported.

int num_blocks = (int)m_save_data.size();
p.Do(num_blocks);
m_save_data.resize(num_blocks);
for (auto itr = m_save_data.begin(); itr != m_save_data.end(); ++itr)
{
p.DoPOD<GCMBlock>(*itr);
}
p.Do(m_save_data);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is mostly equivalent (as long as num_blocks is less than INT_MAX, and calling Do n times is the same as calling a larger DoArray, which should be the case for a trivially copyable type):

template <typename T>
void Do(std::vector<T>& x)
{
DoContiguousContainer(x);
}

template <typename T>
void DoContiguousContainer(T& container)
{
u32 size = static_cast<u32>(container.size());
Do(size);
container.resize(size);
if (size > 0)
DoArray(&container[0], size);
}

template <typename T, typename std::enable_if_t<std::is_trivially_copyable_v<T>, int> = 0>
void DoArray(T* x, u32 count)
{
DoVoid(x, count * sizeof(T));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I think you're right that this is equivalent, I think I'd feel safer if you bumped up the savestate version anyway -- #11125 is going to bump it too so it's no big deal to have a break here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also changed the similar manual std::vector handling in GCMemcardDirectory.cpp.

This was added in 385d8e2, but became somewhat redundant with Do in 4c7bbd9, and completely redundant now that std::is_trivially_copyable_v is well-supported.
@AdmiralCurtiss AdmiralCurtiss merged commit 09c5b58 into dolphin-emu:master Oct 6, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants