Skip to content

Commit 54328e8

Browse files
omohokcojJosé Valim
authored andcommitted
Optimize Enum.join/2 with empty string (#9697)
1 parent a256c55 commit 54328e8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/elixir/lib/enum.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,12 @@ defmodule Enum do
13541354
@spec join(t, String.t()) :: String.t()
13551355
def join(enumerable, joiner \\ "")
13561356

1357+
def join(enumerable, "") do
1358+
enumerable
1359+
|> map(&entry_to_string(&1))
1360+
|> IO.iodata_to_binary()
1361+
end
1362+
13571363
def join(enumerable, joiner) when is_binary(joiner) do
13581364
reduced =
13591365
reduce(enumerable, :first, fn

0 commit comments

Comments
 (0)