Improve performance of join/1 on large arrays (#3639)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
join/1 folded each element as `(acc + $x) + elem`, with the element branch ending in `.//""`. Both leave a second live reference to the accumulator: the nested + feeds the same `.` to both operands, and the `//` leaves a forkpoint below it on the stack. `jvp_string_append` therefore cannot grow the accumulator in place, and copies the whole string once per element. Pipe `acc + $x` into `. + elem` and drop the `//`, since adding null to a string is already a no-op. join/1 is now linear: joining 8000 strings of 1000 chars goes from 6.5s to 0.06s, with output and error messages unchanged.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+12 added−2 removed
- tests:+8 added−0 removed
- other:+4 added−2 removed