0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Use map syntax instead of maps:put/3

This commit is contained in:
Loïc Hoguin 2015-07-27 17:32:05 +02:00
parent ccd786baee
commit d043148f4a

View file

@ -1194,13 +1194,13 @@ kvlist_to_map(Keys, [{Key, Value}|Tail], Map) ->
case maps:find(Atom, Map) of
{ok, MapValue} when is_list(MapValue) ->
kvlist_to_map(Keys, Tail,
maps:put(Atom, [Value|MapValue], Map));
Map#{Atom => [Value|MapValue]});
{ok, MapValue} ->
kvlist_to_map(Keys, Tail,
maps:put(Atom, [Value, MapValue], Map));
Map#{Atom => [Value, MapValue]});
error ->
kvlist_to_map(Keys, Tail,
maps:put(Atom, Value, Map))
Map#{Atom => Value})
end;
false ->
kvlist_to_map(Keys, Tail, Map)
@ -1221,7 +1221,7 @@ filter([{Key, Constraints, Default}|Tail], Map) ->
{ok, Value} ->
filter_constraints(Tail, Map, Key, Value, Constraints);
error ->
filter(Tail, maps:put(Key, Default, Map))
filter(Tail, Map#{Key => Default})
end;
filter([Key|Tail], Map) ->
true = maps:is_key(Key, Map),
@ -1232,7 +1232,7 @@ filter_constraints(Tail, Map, Key, Value, Constraints) ->
true ->
filter(Tail, Map);
{true, Value2} ->
filter(Tail, maps:put(Key, Value2, Map))
filter(Tail, Map#{Key => Value2})
end.
%% Tests.