diff options
author | Björn Gustavsson <[email protected]> | 2019-06-27 13:15:26 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-06-27 13:15:26 +0200 |
commit | 3a7c035afbb3ec50c4dfab1b29516e5b54c0cbcc (patch) | |
tree | 7534634b96f332e4fab9fc46ab13bd14301490a2 /lib/stdlib/src | |
parent | 4be7ac22d77680cf36302b3d6f37c5fe4cac7f2a (diff) | |
download | otp-3a7c035afbb3ec50c4dfab1b29516e5b54c0cbcc.tar.gz otp-3a7c035afbb3ec50c4dfab1b29516e5b54c0cbcc.tar.bz2 otp-3a7c035afbb3ec50c4dfab1b29516e5b54c0cbcc.zip |
Optimize ordsets:union/1
`ordsets:union/1` is not especially efficient when calculating the
union of many ordsets. Rewrite it to use the highly optimized
`lists:umerge/1`.
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/ordsets.erl | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/stdlib/src/ordsets.erl b/lib/stdlib/src/ordsets.erl index 176047079b..95b83ded8c 100644 --- a/lib/stdlib/src/ordsets.erl +++ b/lib/stdlib/src/ordsets.erl @@ -150,13 +150,8 @@ union(Es1, []) -> Es1. OrdsetList :: [ordset(T)], Ordset :: ordset(T). -union([S1,S2|Ss]) -> - union1(union(S1, S2), Ss); -union([S]) -> S; -union([]) -> []. - -union1(S1, [S2|Ss]) -> union1(union(S1, S2), Ss); -union1(S1, []) -> S1. +union(OrdsetList) -> + lists:umerge(OrdsetList). %% intersection(OrdSet1, OrdSet2) -> OrdSet. %% Return the intersection of OrdSet1 and OrdSet2. |