I hope escape analysis (does it already work in modern js engines?) would help to eliminate array allocation...