Replace pipeline with a function
The given example of "replace a pipeline with a function" is really an example of "use a higher order version of a function to reduce the number of functions called and enumerations performed". The reason I bring this up is that if there were further pipes in the example, the refactor wouldn't remove the pipes - it would simply be changing the function call.
# given
list
|> Enum.filter(&is_foo/1)
|> Enum.count()
|> do_more_work()
# the refactor would be
list
|> Enum.count(&is_foo/1)
|> do_more_work()
adobe's styler tool performs a large number of these optimizing refactors across pipes whenever code is formatted via mix format
(the exact filter |> count implementation is here)
Replace pipeline with a function
The given example of "replace a pipeline with a function" is really an example of "use a higher order version of a function to reduce the number of functions called and enumerations performed". The reason I bring this up is that if there were further pipes in the example, the refactor wouldn't remove the pipes - it would simply be changing the function call.
adobe's styler tool performs a large number of these optimizing refactors across pipes whenever code is formatted via
mix format(the exact
filter |> countimplementation is here)