Re: Constructive criticism
- Posted by mattlewis (admin) Mar 09, 2009
- 1240 views
Critic said...
mattlewis said...
In fact, what happens is that repeated subscripting stacks[stack][$] requires extra references (basically, assignments to temporary variables), and requires more copy on writes.
Why? There is no need for this.
I think you're right. In fact, this morning, we were just having a discussion about this on the dev list. I was basing this on the translator (since it's easier to see what's going on at that level), and there appear to be some extra reference counts added for the RHS_SUBS opcode.
It seems that sometimes it's necessary, and for others, it is not. In particular, it's not really required for:
if length(stacks[stack]) then
I think that the issue is something like, if it's part of an assign statement, it should be ref'd, but not if it isn't:
if length(stacks[stack]) then -- vs stacks[stack][$] = stacks[stack][$-1]
Matt