on master help sign in
Fix Array.append with small arrays

Reshuffling in RRB-Trees is only reasonable when appending arrays higher than leaf level. That is why calcToRemove and shuffle are only implemented for those arrays. When appeding two leafes we can just give them a parent node. Fixes #806

commit98298839481cdf379f7c40e7f14f930165adc558 authorChristian Widera <xash@posteo.de> dateMon 13 Oct 2014, 23:26 (12 years ago) parentd24639d
1 file changed+5−3
libraries/Native/Array.js+5−3
libraries/Native/Array.js+5−3
@@ -390,9 +390,11 @@ Elm.Native.Array.make = function(elm) {
390390 return c[0];
391391 }
392392
393− var toRemove = calcToRemove(a, b);
394− if (toRemove > E) {
395− c = shuffle(c[0], c[1], toRemove);
393+ if (c[0].height > 0) {
394+ var toRemove = calcToRemove(a, b);
395+ if (toRemove > E) {
396+ c = shuffle(c[0], c[1], toRemove);
397+ }
396398 }
397399
398400 return siblise(c[0], c[1]);