Skip to content

Commit

Permalink
Optimize checking actor gate
Browse files Browse the repository at this point in the history
  • Loading branch information
up2jj committed Apr 5, 2024
1 parent 56a5b8e commit fc14fc2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/fun_with_flags/flag.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,24 @@ defmodule FunWithFlags.Flag do

defp check_actor_gates(gates, item) do
gates
|> actor_gates()
|> do_check_actor_gates(item)
end


Check warning on line 65 in lib/fun_with_flags/flag.ex

View workflow job for this annotation

GitHub Actions / Credo

There should be no trailing white-space at the end of a line.
defp do_check_actor_gates([], _), do: :ignore

defp do_check_actor_gates([gate|rest], item) do

Check warning on line 67 in lib/fun_with_flags/flag.ex

View workflow job for this annotation

GitHub Actions / Credo

There should be no trailing white-space at the end of a line.
defp do_check_actor_gates([%Gate{type: :actor} = gate | rest], item) do
case Gate.enabled?(gate, for: item) do
:ignore -> do_check_actor_gates(rest, item)
result -> result
result -> result
end
end

Check warning on line 74 in lib/fun_with_flags/flag.ex

View workflow job for this annotation

GitHub Actions / Credo

There should be no trailing white-space at the end of a line.
defp do_check_actor_gates([_gate | rest], item) do
do_check_actor_gates(rest, item)
end


Check warning on line 79 in lib/fun_with_flags/flag.ex

View workflow job for this annotation

GitHub Actions / Credo

There should be no trailing white-space at the end of a line.
defp check_group_gates(gates, item) do
gates
|> group_gates()
Expand Down Expand Up @@ -133,10 +137,6 @@ defmodule FunWithFlags.Flag do
Enum.find(gates, &Gate.boolean?/1)
end

defp actor_gates(gates) do
Enum.filter(gates, &Gate.actor?/1)
end

defp group_gates(gates) do
Enum.filter(gates, &Gate.group?/1)
end
Expand Down

0 comments on commit fc14fc2

Please sign in to comment.