on master help sign in
Fix getSlot while
a40ee9aChristian Widera
libraries/Native/Array.js+2−2
@@ -37,7 +37,7 @@ Elm.Native.Array.make = function(elm) {
37 for (var x = array.height; x > 0; x--) {
37 for (var x = array.height; x > 0; x--) {
38 var slot = i >> (x * 5);
38 var slot = i >> (x * 5);
39 if (slot > 0) {
39 if (slot > 0) {
40− while (array.lengths[slot - 1] > i) { slot--; }
40+ while (array.lengths[slot - 1] >= i) { slot--; }
41 i -= array.lengths[slot - 1];
41 i -= array.lengths[slot - 1];
42 }
42 }
43 array = array.table[slot];
43 array = array.table[slot];
@@ -542,7 +542,7 @@ Elm.Native.Array.make = function(elm) {
542 // find the exact slot via forward searching in "lengths". Returns the index.
542 // find the exact slot via forward searching in "lengths". Returns the index.
543 function getSlot(i, a) {
543 function getSlot(i, a) {
544 var slot = i >> (5 * a.height);
544 var slot = i >> (5 * a.height);
545− while (a.lengths[slot - 1] > i) { slot--; }
545+ while (a.lengths[slot - 1] >= i) { slot--; }
546 return slot;
546 return slot;
547 }
547 }
548
548