@@ -35,9 +35,11 @@ Elm.Native.Array.make = function(elm) {
3535
3636 function unsafeGet(i, array) {
3737 for (var x = array.height; x > 0; x--) {
38− var slot = Math.floor(i / cache[x]);
39− while (array.lengths[slot] <= i) { slot++; }
40− if (slot > 0) { i -= array.lengths[slot - 1]; }
38+ var slot = i >> (x * 5);
39+ if (slot > 0) {
40+ while (array.lengths[slot - 1] > i) { slot--; }
41+ i -= array.lengths[slot - 1];
42+ }
4143 array = array.table[slot];
4244 }
4345 return array.table[i];
@@ -530,18 +532,12 @@ Elm.Native.Array.make = function(elm) {
530532 }
531533 }
532534
533− // Cache for Math.pow(M, i)
534− cache = new Array(10);
535− for (var i = 0; i < cache.length; i++) {
536− cache[i] = Math.pow(M, i);
537− }
538−
539535 // Calculates in which slot of "table" the item probably is, then
540536 // find the exact slot via forward searching in "lengths". Returns the index.
541537 function getSlot(i, a) {
542− var slot = Math.floor(i / cache[a.height]);
543− while (a.lengths[slot] <= i) {
544− slot++
538+ var slot = i << (5 * a.height);
539+ while (a.lengths[slot - 1] > i) {
540+ slot++;
545541 }
546542 return slot;
547543 }