hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.4k stars 2.19k forks source link

Optimize "Buffer" with a new data structure #19644

Open hrydgard opened 7 hours ago

hrydgard commented 7 hours ago

Buffer is a class used as a byte queue. Unfortunately it was (long ago) implemented with a vector, which was very slow when trying to parse data piece by piece directly from it, as noticed with the struct viewer by @kotcrab and tested by @Nemoumbra .

This adds a new data structure specially intended for being fast to push to and to read from, even in debug builds, while still being reasonably memory efficient - the CharQueue. Then we replace the internals of Buffer with it.