Skip to content

Commit b4b3abc

Browse files
authored
Optimize class_attribute_list iodata construction (#4192)
Avoids unnecessary list wrapping and uses ?\s instead of " " to build flatter iodata, yielding a ~10% speedup when encoding class attributes.
1 parent 447d163 commit b4b3abc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/phoenix_live_view/html_engine.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ defmodule Phoenix.LiveView.HTMLEngine do
186186
class_attribute_list(t, class_attribute_list(h, acc))
187187
end
188188

189-
defp class_attribute_list([h | t], []), do: class_attribute_list(t, [to_string(h)])
190-
defp class_attribute_list([h | t], acc), do: class_attribute_list(t, [acc, " ", to_string(h)])
189+
defp class_attribute_list([h | t], []), do: class_attribute_list(t, to_string(h))
190+
defp class_attribute_list([h | t], acc), do: class_attribute_list(t, [acc, ?\s, to_string(h)])
191191

192192
@doc false
193193
def empty_attribute_encode(nil), do: ""

0 commit comments

Comments
 (0)