Re: Constructive criticism
- Posted by mattlewis (admin) Mar 09, 2009
- 1309 views
DerekParnell said...
The first thing to note is that you have reminded me of that optimisation technique. Your version of the routine takes half the time than my original one. Even though you seem to be saying that it should be slower, it is fact much faster.
In fact, what happens is that repeated subscripting stacks[stack][$] requires extra references (basically, assignments to temporary variables), and requires more copy on writes. In particular, Derek's code causes two copies, while Critic's causes only one. So there are two savings, in that fewer copies are made, and fewer subscript operations are made.
The difference would be more pronounced with larger stacks.
Matt