From 3ffed207dffdaad6924e3333f8ee30ac5920aa24 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Thu, 13 Apr 2017 15:53:48 +0200 Subject: dialyzer: Do not use two records for PLTs Instead of two records, #plt{} with dict:s and #mini_plt{} with ETS tables, one record is used for representing PLT:s in RAM. The #mini_plt{} is the one now used throughout analyses, but it is called #plt{}. When writing the PLT to file, another record is used, #file_plt{} (as before). When creating #file_plt{}, the #plt{} is deleted (it cannot be used for further analyses). --- lib/dialyzer/src/dialyzer_utils.erl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lib/dialyzer/src/dialyzer_utils.erl') diff --git a/lib/dialyzer/src/dialyzer_utils.erl b/lib/dialyzer/src/dialyzer_utils.erl index 0dbb2bcf0a..511a6d66bf 100644 --- a/lib/dialyzer/src/dialyzer_utils.erl +++ b/lib/dialyzer/src/dialyzer_utils.erl @@ -40,6 +40,7 @@ src_compiler_opts/0, refold_pattern/1, ets_tab2list/1, + ets_move/2, parallelism/0, family/1 ]). @@ -998,18 +999,26 @@ label(Tree) -> %% ets:tab2list(T), ets:delete(T) %% to save some memory at the expense of somewhat longer execution time. ets_tab2list(T) -> - tab2list(ets:first(T), T, []). + F = fun(Vs, A) -> Vs ++ A end, + ets_take(ets:first(T), T, F, []). -tab2list('$end_of_table', T, A) -> +-spec ets_move(From :: ets:tid(), To :: ets:tid()) -> 'ok'. + +ets_move(T1, T2) -> + F = fun(Es, A) -> true = ets:insert(T2, Es), A end, + [] = ets_take(ets:first(T1), T1, F, []), + ok. + +ets_take('$end_of_table', T, F, A) -> case ets:first(T) of % no safe_fixtable()... '$end_of_table' -> A; - Key -> tab2list(Key, T, A) + Key -> ets_take(Key, T, F, A) end; -tab2list(Key, T, A) -> +ets_take(Key, T, F, A) -> Vs = ets:lookup(T, Key), Key1 = ets:next(T, Key), - ets:delete(T, Key), - tab2list(Key1, T, Vs ++ A). + true = ets:delete(T, Key), + ets_take(Key1, T, F, F(Vs, A)). -spec parallelism() -> integer(). -- cgit v1.2.3