on master help sign in
Fix naming in set
a969e0dChristian Widera
libraries/Native/Array.js+10−8
@@ -54,17 +54,19 @@ Elm.Native.Array.make = function(elm) {
54 return unsafeSet(i, item, array);
54 return unsafeSet(i, item, array);
55 }
55 }
56
56
57− function unsafeSet(i, item, a) {
57+ function unsafeSet(i, item, array) {
58− var newA = nodeCopy(a);
58+ array = nodeCopy(array);
59
59
60− if (a.height == 0) {
60+ if (array.height == 0) {
61− newA.table[i] = item;
61+ array.table[i] = item;
62 } else {
62 } else {
63− var slot = getSlot(i, a);
63+ var slot = getSlot(i, array);
64+ if (slot > 0) {
64− var sub = slot > 0 ? a.lengths[slot-1] : 0;
65+ i -= array.lengths[slot - 1];
66+ }
65− newA.table[slot] = unsafeSet(i - sub, item, a.table[slot]);
67+ array.table[slot] = unsafeSet(i, item, array.table[slot]);
66 }
68 }
67− return newA;
69+ return array;
68 }
70 }
69
71
70 function initialize(len, f) {
72 function initialize(len, f) {