Files
n8n-openai-adapter/lib/elixir
Preston Guillory f82f2c7b3e Optimize Enum.unzip/1 for lists (#10963)
The existing unzip implementation is generic for all enumerable types.
However, large optimizations are available if the input is a list.

First, instead of doing two reverse operations at the end, we can do
one at the beginning. This optimization is unavailable in the existing
generic implementation in order to avoid materializing an enumerable
that might be generated lazily.

Second, we can accumulate the two output lists in two separate parameters,
rather than in the reduce function's accumulator. This avoids generating a
tuple per input element that would just be matched away and discarded
by Enum.reduce/3.

Testing with Benchfella shows a roughly 2x to 3x performance improvement
depending on the size of the list.
2021-05-19 12:08:09 +02:00
..
2021-05-14 07:38:51 +02:00
2020-09-07 14:25:55 +02:00
2017-10-08 19:34:44 +02:00