diff options
author | Björn Gustavsson <bjorn@erlang.org> | 2022-11-03 14:11:57 +0100 |
---|---|---|
committer | Björn Gustavsson <bjorn@erlang.org> | 2023-02-02 06:06:26 +0100 |
commit | c36afb8996b3851d907acc46fe8c3ba9ff6c5a4b (patch) | |
tree | c380bcdeaf500b9fc496a966b6e840a9a1aa7028 /lib/dialyzer | |
parent | a3294534f5b08523b25101ab402c80378fdb1ea0 (diff) | |
download | erlang-c36afb8996b3851d907acc46fe8c3ba9ff6c5a4b.tar.gz |
dialyzer_typesig: Optimize lookup_type/2
This function is called very frequently. Use the map syntax instead of
calling the `maps` module.
While at it, remove ancient out-commented code.
Diffstat (limited to 'lib/dialyzer')
-rw-r--r-- | lib/dialyzer/src/dialyzer_typesig.erl | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/dialyzer/src/dialyzer_typesig.erl b/lib/dialyzer/src/dialyzer_typesig.erl index 2224ec8dba..0f08ea560e 100644 --- a/lib/dialyzer/src/dialyzer_typesig.erl +++ b/lib/dialyzer/src/dialyzer_typesig.erl @@ -2391,20 +2391,15 @@ unsafe_lookup_type(Key, Map) -> unsafe_lookup_type_list(List, Map) -> [unsafe_lookup_type(X, Map) || X <- List]. -lookup_type(Key, Map) when is_integer(Key) -> - case maps:find(Key, Map) of - error -> t_any(); - {ok, Val} -> Val - end; lookup_type(#fun_var{'fun' = Fun}, Map) -> Fun(Map); +lookup_type(Key, Map) when is_integer(Key) -> + case Map of + #{Key := Val} -> Val; + #{} -> t_any() + end; lookup_type(Key, Map) -> - %% Seems unused and dialyzer complains about it -- commented out. - %% case cerl:is_literal(Key) of - %% true -> t_from_term(cerl:concrete(Key)); - %% false -> t_subst(Key, Map). - %% end. mk_var(Var) -> case cerl:is_literal(Var) of |