aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2016-12-19 17:03:45 +0100
committerBjörn-Egil Dahlberg <[email protected]>2016-12-19 17:03:45 +0100
commitcc2a8bc4a21b51bf7370f47ba87a593f341de588 (patch)
tree3fae05695cc52328d9b1ec358ea7086b99f905a8 /lib
parentb2b7bf59a24f140e8d7fc46af0bc499a1044ccdd (diff)
parentb326cd3bd5cea325de4b48a94a4a6ffc545f956f (diff)
downloadotp-cc2a8bc4a21b51bf7370f47ba87a593f341de588.tar.gz
otp-cc2a8bc4a21b51bf7370f47ba87a593f341de588.tar.bz2
otp-cc2a8bc4a21b51bf7370f47ba87a593f341de588.zip
Merge branch 'egil/public_key/use-maps-instead-of-dict/OTP-14111'
Diffstat (limited to 'lib')
-rw-r--r--lib/public_key/src/public_key.erl23
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;