Optimisation: from main ink commit 20/12/16
Optimisation: from main ink commit 20/12/16

Simple optimisation that should improve running times significantly. (Ported from main ink repo.)
y-lohse/inkjs,y-lohse/inkjs,y-lohse/inkjs