From 99e0d8ea80ffa700afacb3bdc27d5cac9be686ec Mon Sep 17 00:00:00 2001 From: Aleksei Magusev Date: Wed, 25 Nov 2015 23:56:45 +0100 Subject: [PATCH] Use `:lists.map` instead of hand-written recursion --- lib/elixir/lib/enum.ex | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/elixir/lib/enum.ex b/lib/elixir/lib/enum.ex index 6d957e0e4e..feda087e98 100644 --- a/lib/elixir/lib/enum.ex +++ b/lib/elixir/lib/enum.ex @@ -1084,12 +1084,8 @@ defmodule Enum do @spec map(t, (element -> any)) :: list def map(enumerable, fun) - def map([], _fun) do - [] - end - - def map([head | tail], fun) do - [fun.(head) | map(tail, fun)] + def map(enumerable, fun) when is_list(enumerable) do + :lists.map(fun, enumerable) end def map(enumerable, fun) do