ThirteenAG / GTAIV.EFLC.FusionFix

This project aims to fix or address some issues in Grand Theft Auto IV: The Complete Edition
GNU General Public License v3.0
846 stars 38 forks source link

[Proof of concept] Migrate to SIMDString #498

Closed juicermv closed 1 month ago

juicermv commented 1 month ago

So, some context. SIMDString is an extremely fast string library specifically created for gamedev by Roblox Research. It is reportedly 10-100x faster than std::string and is 100% compatible with it. It is also faster than std::string_view, and can be natively converted to it where needed.

I don't have specific benchmarks but after implementing it in my mod, SA GPS Redux, there's a noticeable improvement in frametimes and frame smoothness. Using it instead of std::string also reduced the final size of the built asi by around 1/4 or so.

Now, due to windows.h redefining std::min and std::max as macros I had to undefine them but the code is fine. ~~At the moment it doesn't build for me though, I'm getting a weird linking error that I've literally never seen anywhere else and googling literally any part of it yields no actual results: Details Error LNK2001 unresolved external symbol "bool __cdecl inConstSegment(char const *)"~~

This might be related to the undefines though, so it should be relatively easy to fork SIMDString and make it compatible with windows.h if necessary.

Ideally, I think it would be practical to implement this into the hooking and ini libraries as well instead of std::string. I personally have already created a mINI fork utilizing it.

Anyway, I don't expect this to be merged. Again this is just a proof of concept to raise awareness about this cool thing!

P.S. I didn't touch nearly as many lines as the diff claims, it's mostly just automatic formatting changes by VS.

juicermv commented 1 month ago

It turns out I just had to build a .lib, which I set up an automated fork to do :) https://github.com/juicermv/SIMDString