@@ -34,12 +34,20 @@ Elm.Native.Array.make = function(elm) {
3434 }
3535
3636 function unsafeGet(i, array) {
37+ var slotSize = Math.pow(M, array.height);
38+
39+ while (true) {
40+ var slot = Math.floor(i / slotSize);
41+ while (array.lengths[slot] <= i) {
42+ slot++;
43+ }
44+ i -= slot > 0 ? array.lengths[slot - 1] : 0;
45+ array = array.table[slot];
3746 if (array.height == 0) {
38− return array.table[i];
47+ return array.table[i];
3948 }
40− var slot = getSlot(i, array);
41− var offset = slot > 0 ? array.lengths[slot-1] : 0;
42− return unsafeGet(i - offset, array.table[slot]);
49+ slotSize /= M;
50+ }
4351 }
4452
4553 // Sets the value at the index i. Only the nodes leading to i will get