Do we know whether or not setting length first creates more memory pressure than if we just keep an index counter and set using indexes instead of push (setting the final length at the end to shorten longer arrays?).  That's the approach we've used elsewhere, and in a naive implementation it would certainly be faster (but I don't know how much it affects performance in the real world).  Is this performance critical code?