libretro / snes9x2010

Snes9x 2010. Port of Snes9x 1.52+ to Libretro (previously called SNES9x Next). Rewritten in C and several optimizations and speedhacks.
Other
98 stars 70 forks source link

Improve save state efficiency + fix save state size #159

Closed jdgleaver closed 2 years ago

jdgleaver commented 2 years ago

At present, every time that retro_serialize_size() is called (i.e whenever save states are used), the core determines the save state size by allocating a temporary 5 MB buffer and writing into this an actual save state. Moreover, it then fails to report the actual size correctly due to a bug in the memory stream wrapper code - which means save states are always 5 MB in size. This represents a terrible inefficiency.

With this PR, the save state size is now calculated independently of regular save state creation. No temporary buffer is required, and there is no need to actually write a save state to memory - and save states now have the correct size (~830 kb)

lgtm-com[bot] commented 2 years ago

This pull request fixes 1 alert when merging 4fc4eec5937e7216c2ec5d9609a81cb695f867ae into 2fa36513b2cb2e4fdd204b91de2808420128d289 - view on LGTM.com

fixed alerts: