diff options
author | Björn-Egil Dahlberg <[email protected]> | 2016-12-16 18:38:56 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2016-12-16 18:38:56 +0100 |
commit | b326cd3bd5cea325de4b48a94a4a6ffc545f956f (patch) | |
tree | b97261960ec9d6165c788f9aba1abf32810f6f49 /lib | |
parent | 248aa0f8a3356e503e6887a0365d66a9f4892528 (diff) | |
download | otp-b326cd3bd5cea325de4b48a94a4a6ffc545f956f.tar.gz otp-b326cd3bd5cea325de4b48a94a4a6ffc545f956f.tar.bz2 otp-b326cd3bd5cea325de4b48a94a4a6ffc545f956f.zip |
public_key: Use maps instead of dict
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public_key/src/public_key.erl | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/public_key/src/public_key.erl b/lib/public_key/src/public_key.erl index 05c09f8996..3d6238d998 100644 --- a/lib/public_key/src/public_key.erl +++ b/lib/public_key/src/public_key.erl @@ -1029,19 +1029,16 @@ do_pkix_crls_validate(OtpCert, [{DP, CRL, DeltaCRL} | Rest], All, Options, Revo end. sort_dp_crls(DpsAndCrls, FreshCB) -> - Sorted = do_sort_dp_crls(DpsAndCrls, dict:new()), - sort_crls(Sorted, FreshCB, []). - -do_sort_dp_crls([], Dict) -> - dict:to_list(Dict); -do_sort_dp_crls([{DP, CRL} | Rest], Dict0) -> - Dict = try dict:fetch(DP, Dict0) of - _ -> - dict:append(DP, CRL, Dict0) - catch _:_ -> - dict:store(DP, [CRL], Dict0) - end, - do_sort_dp_crls(Rest, Dict). + sort_crls(maps:to_list(lists:foldl(fun group_dp_crls/2, + #{}, + DpsAndCrls)), + FreshCB, []). + +group_dp_crls({DP,CRL}, M) -> + case M of + #{DP := CRLs} -> M#{DP := [CRL|CRLs]}; + _ -> M#{DP => [CRL]} + end. sort_crls([], _, Acc) -> Acc; |