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