avoid array exansion and reversal

push() changes the length of the array which has a small cost. also this
way avoids the need for a final reversal which is both slow and ugly
Merge pull request #5 from jkroso/master

final optimisation