Skip to content

Commit

Permalink
combine Enum.filter/2 and Enum.reduce/3 calls
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Dec 6, 2021
1 parent 21d53d4 commit 11dd75e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/finch/http2/pool.ex
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,9 @@ defmodule Finch.HTTP2.Pool do
end

defp continue_requests(data) do
data.requests
|> Enum.filter(fn {_ref, request} -> request.status == :streaming end)
|> Enum.reduce({data, []}, fn {ref, request}, {data, actions} ->
with true <- HTTP2.open?(data.conn, :write),
Enum.reduce(data.requests, {data, []}, fn {ref, request}, {data, actions} ->
with true <- request.status == :streaming,
true <- HTTP2.open?(data.conn, :write),
{:ok, data, new_actions} <- continue_request(data, ref) do
{data, new_actions ++ actions}
else
Expand Down

0 comments on commit 11dd75e

Please # to comment.