elixir-lang/elixir — pull request #2666 by hamiltop (2014-08-11 07:46:34+00:00)
Title: Add special case for lists in Stream.cycle

Performance improvement demonstrated:

```elixir
iex(5)> :timer.tc fn -> Stream.cycle(1..3) |> Enum.take(1_000_000) end
{387861,
[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2,
3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, ...]}
iex(6)> :timer.tc fn -> Stream.cycle([1,2,3]) |> Enum.take(1_000_000) end
{145768,
[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2,
3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, ...]}
iex(7)> Protocol.consolidated?(Enumerable)
true
```