Continuing stack performance improvements
Project: SmallForth
To continue the performance improvements, I have updated the most-frequently used stack-pull calls, to pull-as-a-type, such PullAsInt() or PullAsChar(). This involves checking for stack-underflow before calling this, as opposed to reacting to a StackElement* of nullptr after the call to the generic Pull().
Part of this work also involved ensuring that any code that still Pushed a raw StackElement*, never re-used that pointing after giving it to the DataStack. This is because the DataStack would copy the contained from the pushed pter, and then immediately delete the pter. Previously this was pushed onto a to-be-deleted collection, though, this collection was never deleted from. This to-be-deleted collection has now been removed.
Duplicate, drop, swap and getTOSType are now implemented in the DataStack directly.
The tests from the previous post on performance improvements now result in 0.850343 seconds for test 1, and 1.35942 seconds for test 2. This is down from the original 1.28 and 1.95 seconds originally.
Test 2 was highly reliant on i/o, so the improvements weren't as large.
Further work can be done, as no where should be pulling StackElement* directly from the stack, however there are so many places this is done. From an optimisation standpoint there is little to be gained.