c3d / db48x

RPL runtime for the DM42 calculator, in the spirit of HP48/49/50
http://48calc.org
GNU Lesser General Public License v3.0
114 stars 14 forks source link

Optimize the cleanup of transitory objects #1291

Closed c3d closed 2 weeks ago

c3d commented 3 weeks ago

When we do the evaluation of a complicated operation, e.g. a transcendental function, we tend to perform a large number of temporary operations that create throw-away objects.

Add a cleanup class that takes care of saving the current temporary pointer, and if there was no garbage collection in the meantime, moves the resulting object at that location, essentially clearing all the intermediate objects.