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
Conversation
| 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); |
There was a problem hiding this comment.
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):
dolphin/Source/Core/Common/ChunkFile.h
Lines 125 to 129 in de5a98a
| template <typename T> | |
| void Do(std::vector<T>& x) | |
| { | |
| DoContiguousContainer(x); | |
| } |
dolphin/Source/Core/Common/ChunkFile.h
Lines 319 to 328 in de5a98a
| 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); | |
| } |
dolphin/Source/Core/Common/ChunkFile.h
Lines 198 to 202 in de5a98a
| 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)); | |
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
52a34e3
to
4d33f6a
Compare
This was added in 385d8e2, but became somewhat redundant with Do in 4c7bbd9, and completely redundant now that
std::is_trivially_copyable_vis well-supported.