Skip to content

Commit

Permalink
Small optimization in Stream.Reducers.chunk_every/5 (elixir-lang#8206)
Browse files Browse the repository at this point in the history
Due to the check `acc_count >= limit` inside `chunk_fun`, `acc_count` can only be greater than `count` if `step` is bigger than `count`, there is no need for this check.
  • Loading branch information
ggcampinho authored and josevalim committed Sep 20, 2018
1 parent 7b17320 commit 13ced80
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/elixir/lib/stream/reducers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Stream.Reducers do
end

after_fun = fn {acc_buffer, acc_count} ->
if leftover == :discard or acc_count == 0 or (step > count and acc_count >= count) do
if leftover == :discard or acc_count == 0 or acc_count >= count do
{:cont, []}
else
{:cont, :lists.reverse(acc_buffer, Enum.take(leftover, count - acc_count)), []}
Expand Down

0 comments on commit 13ced80

Please sign in to comment.