From b077c38a0dc3900708d5505a459b44c4207b1b14 Mon Sep 17 00:00:00 2001 From: preciz Date: Sun, 19 Jul 2026 14:20:09 +0200 Subject: [PATCH 1/2] Optimize disjoint function argument checks Assisted-by: Codex:GPT-5.6 Sol Avoid allocating a zipped list before checking whether function domains are disjoint. Representative multi-clause type analysis runs 20-28% faster. --- lib/elixir/lib/module/types/descr.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/elixir/lib/module/types/descr.ex b/lib/elixir/lib/module/types/descr.ex index 17ea122068c..653ac55f980 100644 --- a/lib/elixir/lib/module/types/descr.ex +++ b/lib/elixir/lib/module/types/descr.ex @@ -1871,10 +1871,13 @@ defmodule Module.Types.Descr do end # For two arguments to be disjoint, one of their types must be disjoint. - defp disjoint_arguments?(args1, args2) do - Enum.any?(Enum.zip(args1, args2), fn {t1, t2} -> disjoint?(t1, t2) end) + defp disjoint_arguments?([type1 | args1], [type2 | args2]) do + disjoint?(type1, type2) or disjoint_arguments?(args1, args2) end + defp disjoint_arguments?([], _args2), do: false + defp disjoint_arguments?(_args1, []), do: false + defp all_disjoint_arguments?([]), do: true defp all_disjoint_arguments?([bdd_leaf(args, _) | rest]) do From 9ef9dfa4002c6860bc0a694ac9840e37fe66c891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 19 Jul 2026 16:52:33 +0200 Subject: [PATCH 2/2] Apply suggestion from @josevalim --- lib/elixir/lib/module/types/descr.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/elixir/lib/module/types/descr.ex b/lib/elixir/lib/module/types/descr.ex index 653ac55f980..f02b6ba8b61 100644 --- a/lib/elixir/lib/module/types/descr.ex +++ b/lib/elixir/lib/module/types/descr.ex @@ -1875,8 +1875,7 @@ defmodule Module.Types.Descr do disjoint?(type1, type2) or disjoint_arguments?(args1, args2) end - defp disjoint_arguments?([], _args2), do: false - defp disjoint_arguments?(_args1, []), do: false + defp disjoint_arguments?([], []), do: false defp all_disjoint_arguments?([]), do: true