on master help sign in
Fix naming in set
commita969e0d88a66538fc1c21021ae364d03d3fcd593 authorChristian Widera <xash@posteo.de> dateWed 23 Apr 2014, 12:47 (13 years ago) parenta05e576
1 file changed+10−8
libraries/Native/Array.js+10−8
libraries/Native/Array.js+10−8
@@ -54,17 +54,19 @@ Elm.Native.Array.make = function(elm) {
5454 return unsafeSet(i, item, array);
5555 }
5656
57− function unsafeSet(i, item, a) {
58− var newA = nodeCopy(a);
57+ function unsafeSet(i, item, array) {
58+ array = nodeCopy(array);
5959
60− if (a.height == 0) {
61− newA.table[i] = item;
60+ if (array.height == 0) {
61+ array.table[i] = item;
6262 } else {
63− var slot = getSlot(i, a);
64− var sub = slot > 0 ? a.lengths[slot-1] : 0;
65− newA.table[slot] = unsafeSet(i - sub, item, a.table[slot]);
63+ var slot = getSlot(i, array);
64+ if (slot > 0) {
65+ i -= array.lengths[slot - 1];
66+ }
67+ array.table[slot] = unsafeSet(i, item, array.table[slot]);
6668 }
67− return newA;
69+ return array;
6870 }
6971
7072 function initialize(len, f) {