-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize :term #13625
Optimize :term #13625
Conversation
@@ -783,6 +844,10 @@ defmodule Module.Types.Descr do | |||
end) | |||
end) | |||
end) | |||
|> case do | |||
[] -> 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gldubc you will have to do the same for tuples. We no longer match empty list as empty on intersection/difference. It is either zero or an empty map.
9620a97
to
c16befc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 👍🏻
defguardp is_optional(map) | ||
when is_map(map) and | ||
((is_map_key(map, :bitmap) and (map.bitmap &&& @bit_optional) != 0) or | ||
(is_map_key(map, :dynamic) and is_map(map.dynamic) and | ||
is_map_key(map.dynamic, :bitmap) and | ||
(map.dynamic.bitmap &&& @bit_optional) != 0)) | ||
|
||
defguardp is_optional_static(map) | ||
when is_map(map) and is_map_key(map, :bitmap) and (map.bitmap &&& @bit_optional) != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defguardp is_optional(map) | |
when is_map(map) and | |
((is_map_key(map, :bitmap) and (map.bitmap &&& @bit_optional) != 0) or | |
(is_map_key(map, :dynamic) and is_map(map.dynamic) and | |
is_map_key(map.dynamic, :bitmap) and | |
(map.dynamic.bitmap &&& @bit_optional) != 0)) | |
defguardp is_optional_static(map) | |
when is_map(map) and is_map_key(map, :bitmap) and (map.bitmap &&& @bit_optional) != 0 | |
defguardp is_optional_static(map) | |
when is_map(map) and is_map_key(map, :bitmap) and (map.bitmap &&& @bit_optional) != 0 | |
defguardp is_optional(map) | |
when is_optional_static(map) or | |
(is_map(map) and is_map_key(map, :dynamic) and is_optional_static(map.dynamic)) |
possibly easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check later if the Erlang compiler optimizes the duplicate checks efficiently and merge your proposal. :)
💚 💙 💜 💛 ❤️ |
No description provided.