@@ -35,9 +35,11 @@ Elm.Native.Array.make = function(elm) {
36 function unsafeGet(i, array) {
36 function unsafeGet(i, array) {
37 for (var x = array.height; x > 0; x--) {
37 for (var x = array.height; x > 0; x--) {
38− var slot = Math.floor(i / cache[x]);
38+ var slot = i >> (x * 5);
39− while (array.lengths[slot] <= i) { slot++; }
39+ if (slot > 0) {
40+ while (array.lengths[slot - 1] > i) { slot--; }
40− if (slot > 0) { i -= array.lengths[slot - 1]; }
41+ i -= array.lengths[slot - 1];
41 array = array.table[slot];
43 array = array.table[slot];
43 return array.table[i];
45 return array.table[i];
@@ -530,18 +532,12 @@ Elm.Native.Array.make = function(elm) {
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);
539 // Calculates in which slot of "table" the item probably is, then
535 // Calculates in which slot of "table" the item probably is, then
540 // find the exact slot via forward searching in "lengths". Returns the index.
536 // find the exact slot via forward searching in "lengths". Returns the index.
541 function getSlot(i, a) {
537 function getSlot(i, a) {
542− var slot = Math.floor(i / cache[a.height]);
538+ var slot = i << (5 * a.height);
543− while (a.lengths[slot] <= i) {
539+ while (a.lengths[slot - 1] > i) {
546 return slot;
542 return slot;