katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
81 stars 4 forks source link

Dev 3.1.0 - Added in clearing locals (by resizing them) #116

Closed tabularelf closed 2 months ago

tabularelf commented 2 months ago

I've implemented a way of clearing locals in my own game awhile ago. Given that any structs passed into a function linger around until the function is recalled, where at that point locals are refreshed.

This PR aims to improve that by clearing locals at the very end, resolving #91. I've taken the array_resize approach, as loops aren't anywhere near as fast as array_resize the more locals there is needed to be cleared. Looping is only really beneficial if the local count is very low, and on YYC. I also have moved localCount to the top of the function, as localCount is also used for resetting the locals array back to it's original size.