Skip to content

Commit c39d9ea

Browse files
committed
Add more comments to descr, avoid unnecessary traversals
1 parent 98468bd commit c39d9ea

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

lib/elixir/lib/module/types/descr.ex

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5909,17 +5909,19 @@ defmodule Module.Types.Descr do
59095909
:none when a1 < bdd2 ->
59105910
{a1, bdd_difference(c1, bdd2, leaf_compare), bdd_difference(u1, bdd2, leaf_compare),
59115911
bdd_difference(d1, bdd2, leaf_compare)}
5912-
|> case do
5913-
{_, :bdd_bot, u, :bdd_bot} -> u
5914-
other -> other
5915-
end
59165912

59175913
:none when bdd2 < a1 ->
59185914
{bdd2, :bdd_bot, :bdd_bot, bdd1}
59195915

59205916
:none ->
5917+
# There is no point in traversing down if they are equal,
5918+
# as we can assume this check already happened when building bdd1
59215919
{bdd2, :bdd_bot, :bdd_bot, bdd_union(u1, d1)}
59225920
end
5921+
|> case do
5922+
{_, :bdd_bot, u, :bdd_bot} -> u
5923+
other -> other
5924+
end
59235925
end
59245926

59255927
# For the left-side being a leaf, we have:
@@ -5953,16 +5955,18 @@ defmodule Module.Types.Descr do
59535955
:none when a2 < bdd1 ->
59545956
{a2, bdd_difference(bdd1, bdd_union(c2, u2), leaf_compare), :bdd_bot,
59555957
bdd_difference(bdd1, bdd_union(d2, u2), leaf_compare)}
5956-
|> case do
5957-
{_, :bdd_bot, u, :bdd_bot} -> u
5958-
other -> other
5959-
end
59605958

59615959
:none when bdd1 < a2 ->
59625960
{bdd1, bdd_negation(bdd2), :bdd_bot, :bdd_bot}
59635961

59645962
:none ->
5965-
bdd1 |> bdd_difference(c2, leaf_compare) |> bdd_difference(u2, leaf_compare)
5963+
# There is no point in traversing down if they are equal,
5964+
# as we can assume this check already happened when building bdd2
5965+
{bdd1, bdd_negation(bdd_union(c2, u2)), :bdd_bot, :bdd_bot}
5966+
end
5967+
|> case do
5968+
{_, :bdd_bot, u, :bdd_bot} -> u
5969+
other -> other
59665970
end
59675971
end
59685972

0 commit comments

Comments
 (0)