Skip to content

Conversation

@gldubc
Copy link
Member

@gldubc gldubc commented Nov 12, 2024

Add pruning to tuple_difference and tuple_union. This eliminates obviously empty negations
(such as {integer(), atom()} and not {atom(), ...}) from the representation, which drastically reduces its size in corner cases like the example added.


defp tuple_union(left, right), do: left ++ right
# Removes duplicates in union, which should trickle to other operations.
defp tuple_union(left, right), do: left ++ (right -- left)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is performing structural equality. Should we add a TODO saying this is a cheap optimization?

@josevalim josevalim merged commit 26318eb into elixir-lang:main Nov 12, 2024
12 checks passed
@josevalim josevalim deleted the tuple-diff-optimization branch November 12, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants