GreepTheSheep / openplanet-maniaexchange-menu

TrackmaniaExchange directly on your TrackMania! For TM2020 and MP4
https://openplanet.dev/plugin/maniaexchange
MIT License
10 stars 5 forks source link

`GetCurrentMapInfo` export always serializes json #26

Closed codecat closed 1 month ago

codecat commented 1 month ago

This could be improved for performance, by only serializing once and then returning the same Json::Value@.

GreepTheSheep commented 1 month ago

I don't have the feeling that it does it always, the indicated code takes the MapInfo Class and serializes it in Json::Value only once with ToJson(), unless I forgot something...

https://github.com/GreepTheSheep/openplanet-maniaexchange-menu/blob/main/src/Exports/ExportsCode.as#L26-L29

tbf I don't see where it always serializes json

codecat commented 1 month ago

Every time this function is called, the json is serialized. I've seen a plugin call this function repeatedly every frame, which is obviously a large overhead.

That's of course also a problem in their plugin, but the API isn't explicitly saying that it's going to serialize anything, it's just called GetCurrentMapInfo, which implies all it does it get something.

codecat commented 1 month ago

You have some trace logging left in the referenced commit which may be unexpected for API users. Thanks for the fix!