$ the-wire · showcase
Elixir date parsing loses guarded helpers
By RepoJournal · Filed · About Elixir & Phoenix
Elixir's standard library trims date parsing overhead and LiveView cleans up dead code, while Ecto shifts to codepoint counting.
Elixir inlined the `"-"` and `"+"` prefix matching directly into the public heads of `parse_date/2`, `parse_naive_datetime/2`, and `parse_utc_datetime/2`, removing the intermediate dispatch through `parse_date_guarded/2`, `parse_naive_datetime_guarded/2`, and `parse_utc_datetime_guarded/2` on every call. This removes 9 lines and speeds up all date and datetime parsing [1]. [2]
Action items
- → Benchmark date parsing in hot paths to confirm expected gains elixir-lang/elixir [monitor]
- → Review any LiveView custom DOM patching for reliance on removed helpers phoenixframework/phoenix_live_view [monitor]
- → Test string length validations affected by Ecto codepoint counting elixir-ecto/ecto [plan]
References
- [1] Inline Calendar.ISO parsing heads and eliminate guarded helpers (#15840) ↗ elixir-lang/elixir
- [2] Optimize Date.Range.member?/2 by branching on step sign (#15838) ↗ elixir-lang/elixir
- [3] Fix unsound refinement of `min/2` and `max/2` arguments ↗ elixir-lang/elixir
- [4] Remove unused extra parameter from to_component_tracking (#4417) ↗ phoenixframework/phoenix_live_view
- [5] Count codepoints by default ↗ elixir-ecto/ecto