]> git.corax.cc Git - toolbox/commit
include/array: Improve performance of array_to_lines()
authorMatthias Kruk <m@m10k.eu>
Wed, 2 Feb 2022 11:20:12 +0000 (20:20 +0900)
committerMatthias Kruk <m@m10k.eu>
Wed, 2 Feb 2022 11:20:12 +0000 (20:20 +0900)
commit7a62d607cd963ae917dc96e6c51f67c6bb650e2b
tree74b843c861bb39f64b100e0a2efcef47ac529b29
parent892530e7f0960960d42495f4380e796055838914
include/array: Improve performance of array_to_lines()

`array_to_lines()` calls `echo` for every element in the array, which
is wasteful and scales very poorly.

This commit modifies `array_to_lines()` so that it uses a single call
to `printf` to print all array elements.

This issue was pointed out by reddit user u/oh5nxo.
include/array.sh