GarageGames/Torque3D — pull request #81 by jamesu (2012-10-12 20:34:16+00:00)
Title: Improve Console Function Calls

This branch makes the following changes to the Console/TorqueScript system:

1) Changes the Console Function & Method binding code so values are passed using a native console value wrapper (ConsoleValueRef) instead of just strings.
2) Optimizes the case of "%var = %othervar".
3) Changes the interpreter and compiler to support no.1 and reduce unneccesary type conversion when calling functions.

In essence, this improves the performance of TorqueScript so that calling functions is no longer expensive in the case of passing numbers around. It also optimizes variable assignment, so when assigning numeric variables it will no longer perform an unneccesary string conversion.

Relevant benchmarking figures are available here:

http://www.garagegames.com/community/forums/viewthread/131792/4#comment-834494
http://www.garagegames.com/community/forums/viewthread/131792/5#comment-834766

The actual benchmarking code I used is here: https://gist.github.com/3760645

While I have a few more ideas to improve the scripting engine (e.g. improving field access), I feel that changing the way script functions are binded to the engine is both significant and useful enough to make a pull request now.

This code has been tested on Windows and Linux. It has also been tested in the case of Singleplayer and Multiplayer. Unfortunately while I have tested this as much as I can, there could still be edge cases where this breaks something so I encourage anyone interested in incorporating these changes to test them against their script code.