Files
n8n-openai-adapter/lib/elixir
Tyler A. Young 05576dd133 perf: Speed up Enum.dedup_by/2 on lists via a hand-rolled, tail-recursive implementation (#15815)
This improves the runtime of `Enum.dedup_by/2` on lists by replacting the generic `reduce/3` implementation with a hand-rolled version similar in spirit to the `dedup_list/1` optimization. In my benchmarking, the magnitude of the improvement depends heavily on the size and shape of the data, but it looks roughly like this:

| List length | Duplicates | Speedup |
|          10 |          0 |   +140% |
|       1,000 |          0 |    +81% |
|   1,000,000 |          0 |     +7% |
|          10 |        20% |   +116% |
|       1,000 |        20% |    +64% |
|   1,000,000 |        20% |     +2% |
|          10 |        50% |    +45% |
|       1,000 |        50% |    +62% |
|   1,000,000 |        50% |    +12% |
2026-08-31 17:50:38 +02:00
..
2026-08-20 14:20:40 +02:00