bool is not always guaranteed to be the same size on every platform.
On some platforms it may be one byte, on others it can be 8 bytes if the
platform dictates it. It's implementation-defined.
This can be problematic when it comes to storing this
data to disk (it can also be space-inefficient, but that's not really an
issue). Also say for some reason you moved your savestates to another
platform, it's possible they won't load correctly due to differences in size.
This change stores all bools to savestates as if they were a byte in size
and handles the loading of them accordingly.
Gets rid of magic numbers in cases where the array size is known at compile time.
This is also useful for future entries that are stack allocated arrays as these
functions prevent incorrect sizes being provided.
This is inconsistent with how other containers are used (i.e. with Do()), but making std::array be used with Do() seems rather confusing when there's also a DoArray available.
Decreases total Wii state save time (not counting compression) from
~570ms to ~18ms.
The compiler can't remove this check because of potential aliasing; this
might be fixable (e.g. by making mode const), but there is no reason to
have the code work in such a braindead way in the first place.
- DoVoid now uses memcpy.
- DoArray now uses DoVoid on the whole rather than Doing each element
(would fail for an array of STL structures, but we don't have any of
those).
- Do also now uses DoVoid. (In the previous version, it replicated
DoVoid's code in order to ensure each type gets its own implementation,
which for small types then becomes a simple load/store in any modern
compiler. Now DoVoid is __forceinline, which addresses that issue and
shouldn't make a big difference otherwise - perhaps a few extra copies
of the code inlined into DoArray or whatever.)
This shouldn't really be exposed as a public function and should only be called through other Do class functions that take a container type as a parameter.
Between C++11 and C++14, volatile types stopped being trivially
copyable. The serializer has no reason to care about this distinction,
so tack on remove_volatile.