diff options
author | Hans Bolinder <[email protected]> | 2016-12-28 19:22:42 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-01-11 09:34:59 +0100 |
commit | 5d9e51a4271833855519df37df8f964216a0e594 (patch) | |
tree | 7e1f58c7daa7cd0483b6378694df495e5b2da136 /lib/dialyzer/src/dialyzer_contracts.erl | |
parent | 66d387c039156989a6ea834033888ac50f1efc1e (diff) | |
download | otp-5d9e51a4271833855519df37df8f964216a0e594.tar.gz otp-5d9e51a4271833855519df37df8f964216a0e594.tar.bz2 otp-5d9e51a4271833855519df37df8f964216a0e594.zip |
dialyzer: Use less memory when translating contracts
Diffstat (limited to 'lib/dialyzer/src/dialyzer_contracts.erl')
-rw-r--r-- | lib/dialyzer/src/dialyzer_contracts.erl | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index d3ed4435ad..c0a4c6892c 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -150,8 +150,7 @@ sequence([H|T], Delimiter) -> H ++ Delimiter ++ sequence(T, Delimiter). dialyzer_codeserver:codeserver(). process_contract_remote_types(CodeServer) -> - {TmpContractDict, TmpCallbackDict} = - dialyzer_codeserver:get_temp_contracts(CodeServer), + Mods = dialyzer_codeserver:contracts_modules(CodeServer), ExpTypes = dialyzer_codeserver:get_exported_types(CodeServer), RecordDict = dialyzer_codeserver:get_records(CodeServer), ContractFun = @@ -165,21 +164,22 @@ process_contract_remote_types(CodeServer) -> {{MFA, {File, Contract, Xtra}}, C2} end, ModuleFun = - fun({ModuleName, ContractMap}) -> + fun(ModuleName) -> Cache = erl_types:cache__new(), - {NewContractList, _NewCache} = + {ContractMap, CallbackMap} = + dialyzer_codeserver:get_temp_contracts(ModuleName, CodeServer), + {NewContractList, Cache1} = lists:mapfoldl(ContractFun, Cache, maps:to_list(ContractMap)), - {ModuleName, maps:from_list(NewContractList)} + {NewCallbackList, _NewCache} = + lists:mapfoldl(ContractFun, Cache1, maps:to_list(CallbackMap)), + dialyzer_codeserver:store_contracts(ModuleName, + maps:from_list(NewContractList), + maps:from_list(NewCallbackList), + CodeServer) end, - erlang:garbage_collect(), - NewContractList = lists:map(ModuleFun, dict:to_list(TmpContractDict)), - NewCallbackList = lists:map(ModuleFun, dict:to_list(TmpCallbackDict)), - NewContractDict = dict:from_list(NewContractList), - NewCallbackDict = dict:from_list(NewCallbackList), - %% Make sure temporary data and the (huge) cache are garbage collected: - erlang:garbage_collect(), - dialyzer_codeserver:finalize_contracts(NewContractDict, NewCallbackDict, - CodeServer). + lists:foreach(ModuleFun, Mods), + %% erlang:garbage_collect(), + dialyzer_codeserver:finalize_contracts(CodeServer). -type opaques_fun() :: fun((module()) -> [erl_types:erl_type()]). |