aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2016-02-25 10:45:38 +0100
committerHenrik Nord <[email protected]>2016-02-25 10:45:38 +0100
commit209804f87fa7a11468e5e373217917d2e11fcb9d (patch)
tree00d19e4f316ce25baa11aa1e339f12af1c92ba9c /lib/stdlib/src
parent6fa44b305dea76c1a8850711d4d979d21846c520 (diff)
parent93c6b942bf99e73e566e3ab8c6dea1848a1e4b1e (diff)
downloadotp-209804f87fa7a11468e5e373217917d2e11fcb9d.tar.gz
otp-209804f87fa7a11468e5e373217917d2e11fcb9d.tar.bz2
otp-209804f87fa7a11468e5e373217917d2e11fcb9d.zip
Merge branch 'maint'
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/maps.erl14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/stdlib/src/maps.erl b/lib/stdlib/src/maps.erl
index 3c798b7a04..43d10f4800 100644
--- a/lib/stdlib/src/maps.erl
+++ b/lib/stdlib/src/maps.erl
@@ -205,7 +205,7 @@ size(Val) ->
K :: term().
without(Ks,M) when is_list(Ks), is_map(M) ->
- maps:from_list([{K,V}||{K,V} <- maps:to_list(M), not lists:member(K, Ks)]);
+ lists:foldl(fun(K, M1) -> ?MODULE:remove(K, M1) end, M, Ks);
without(Ks,M) ->
erlang:error(error_type(M),[Ks,M]).
@@ -216,8 +216,16 @@ without(Ks,M) ->
Map2 :: map(),
K :: term().
-with(Ks,M) when is_list(Ks), is_map(M) ->
- maps:from_list([{K,V}||{K,V} <- maps:to_list(M), lists:member(K, Ks)]);
+with(Ks,Map1) when is_list(Ks), is_map(Map1) ->
+ Fun = fun(K, List) ->
+ case ?MODULE:find(K, Map1) of
+ {ok, V} ->
+ [{K, V} | List];
+ error ->
+ List
+ end
+ end,
+ ?MODULE:from_list(lists:foldl(Fun, [], Ks));
with(Ks,M) ->
erlang:error(error_type(M),[Ks,M]).