Skip to content

Commit 47fea95

Browse files
committed
Perform expensive operation once
1 parent 6a6678f commit 47fea95

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4499,8 +4499,14 @@ defmodule Module.Types.Descr do
44994499
bdd_difference(bdd_union(d1, u1), bdd2)}
45004500

45014501
{:gt, bdd1, {lit2, c2, u2, d2}} ->
4502-
{lit2, bdd_difference(bdd1, bdd_union(c2, u2)), :bdd_bot,
4503-
bdd_difference(bdd1, bdd_union(d2, u2))}
4502+
# The proper formula is:
4503+
#
4504+
# b1 and not (c2 or u2) : bdd_bot : b1 and not (d2 or u2)
4505+
#
4506+
# Both extremes have (b1 and not u2),
4507+
# so we compute it first and only once.
4508+
bdd1_minus_u2 = bdd_difference(bdd1, u2)
4509+
{lit2, bdd_difference(bdd1_minus_u2, c2), :bdd_bot, bdd_difference(bdd1_minus_u2, d2)}
45044510

45054511
{:eq, {lit, c1, u1, d1}, {_, c2, u2, d2}} ->
45064512
cond do

0 commit comments

Comments
 (0)