on master help sign in
Preallocate array per Spirros.

Need to specify indices explictly, as push will not overwrite the initialized values but instead appends on to the end.

commitc99d7d72d5f8ff20b49bd99efec3a8de960b2c17 authorMax Goldstein <maxgoldstein1@gmail.com> dateMon 7 Oct 2013, 21:35 (13 years ago) parent4a93227
1 file changed+3−3
libraries/Native/Signal/Random.js+3−3
libraries/Native/Signal/Random.js+3−3
@@ -20,9 +20,9 @@ Elm.Native.Random.make = function(elm) {
2020
2121 function flts(signal) {
2222 function f(x) {
23− var arr = [];
24− for (var i = x; i > 0; i--) {
25− arr.push(Math.random());
23+ var arr = new Array(Math.max(0,x));
24+ for (var i = 0; i < x; i++) {
25+ arr[i] = Math.random();
2626 }
2727 return List.fromArray(arr);
2828 }