Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0283-dialyzer-Optimize-type-limitation.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0283-dialyzer-Optimize-type-limitation.patch of Package erlang
From 89ae5d32b715ae5a2bdba263d97ad853f1f7ab2a Mon Sep 17 00:00:00 2001 From: Hans Bolinder <hasse@erlang.org> Date: Mon, 26 Jul 2021 07:10:29 +0200 Subject: [PATCH 3/7] dialyzer: Optimize type limitation By checking if a type is already limited (erl_types:is_limited()), some allocations can be avoided. --- lib/dialyzer/src/erl_types.erl | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/dialyzer/src/erl_types.erl b/lib/dialyzer/src/erl_types.erl index 03a5082e93..dd76314cdd 100644 --- a/lib/dialyzer/src/erl_types.erl +++ b/lib/dialyzer/src/erl_types.erl @@ -4265,7 +4265,44 @@ t_unopaque(T, _) -> -spec t_limit(erl_type(), integer()) -> erl_type(). t_limit(Term, K) when is_integer(K) -> - t_limit_k(Term, K). + case is_limited(Term, K) of + true -> Term; + false -> t_limit_k(Term, K) + end. + +is_limited(?any, _) -> true; +is_limited(_, K) when K =< 0 -> false; +is_limited(?tuple(?any, ?any, ?any), _K) -> true; +is_limited(?tuple(Elements, _Arity, _), K) -> + if K =:= 1 -> false; + true -> + K1 = K-1, + lists:all(fun(E) -> is_limited(E, K1) end, Elements) + end; +is_limited(?tuple_set(_) = T, K) -> + lists:all(fun(Tuple) -> is_limited(Tuple, K) end, t_tuple_subtypes(T)); +is_limited(?list(Elements, Termination, _Size), K) -> + if K =:= 1 -> is_limited(Termination, K); + true -> is_limited(Termination, K - 1) + end + andalso is_limited(Elements, K - 1); +is_limited(?function(Domain, Range), K) -> + is_limited(Domain, K) andalso is_limited(Range, K-1); +is_limited(?product(Elements), K) -> + K1 = K-1, + lists:all(fun(X) -> is_limited(X, K1) end, Elements); +is_limited(?union(Elements), K) -> + lists:all(fun(X) -> is_limited(X, K) end, Elements); +is_limited(?opaque(Es), K) -> + lists:all(fun(#opaque{struct = S}) -> is_limited(S, K) end, set_to_list(Es)); +is_limited(?map(Pairs, DefK, DefV), K) -> + %% Use the fact that t_sup() does not increase the depth. + K1 = K - 1, + lists:all(fun({Key, _, Value}) -> + is_limited(Key, K1) andalso is_limited(Value, K1) + end, Pairs) + andalso is_limited(DefK, K1) andalso is_limited(DefV, K1); +is_limited(_, _K) -> true. t_limit_k(_, K) when K =< 0 -> ?any; t_limit_k(?tuple(?any, ?any, ?any) = T, _K) -> T; -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor