Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 469a1cc

Browse files
authored
Optimize Access.filter to eliminate intermediate list creation (#14749)
1 parent 4008142 commit 469a1cc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/elixir/lib/access.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ defmodule Access do
891891
end
892892

893893
defp filter(:get, data, func, next) when is_list(data) do
894-
data |> Enum.filter(func) |> Enum.map(next)
894+
for elem <- data, func.(elem), do: next.(elem)
895895
end
896896

897897
defp filter(:get_and_update, data, func, next) when is_list(data) do

0 commit comments

Comments
 (0)