diff --git a/src/builtins/array-join.tq b/src/builtins/array-join.tq index 84b967fa597..3cd384feb02 100644 --- a/src/builtins/array-join.tq +++ b/src/builtins/array-join.tq @@ -467,6 +467,18 @@ transitioning macro ArrayJoinImpl( if (k > 0) { // a. If k > 0, let R be the string-concatenation of R and sep. nofSeparators = nofSeparators + 1; + // --- POC FAST-FORWARD (testing only; not part of fix) --------------- + // The hole-skipping iterations k=1..len-1 each do exactly + // `nofSeparators++` and nothing else (element is kEmptyString → + // `continue`). Collapsing them by jumping (k, nofSeparators) forward + // together is therefore semantically identical to running them. On a + // 32-bit target Signed(len-1) == (int32)(len-1), reproducing the wrap + // that the real ~4e9-iteration loop produces on native arm32/ia32. + if (k == 1 && len > kSmiMaxValue) { + nofSeparators = Signed(len - 1); + k = len - 1; + } + // ------------------------------------------------------------------- } // b. Let element be ? Get(O, ! ToString(k)).