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:
parent
ccd786baee
commit
d043148f4a
1 changed files with 5 additions and 5 deletions
|
@ -1194,13 +1194,13 @@ kvlist_to_map(Keys, [{Key, Value}|Tail], Map) ->
|
||||||
case maps:find(Atom, Map) of
|
case maps:find(Atom, Map) of
|
||||||
{ok, MapValue} when is_list(MapValue) ->
|
{ok, MapValue} when is_list(MapValue) ->
|
||||||
kvlist_to_map(Keys, Tail,
|
kvlist_to_map(Keys, Tail,
|
||||||
maps:put(Atom, [Value|MapValue], Map));
|
Map#{Atom => [Value|MapValue]});
|
||||||
{ok, MapValue} ->
|
{ok, MapValue} ->
|
||||||
kvlist_to_map(Keys, Tail,
|
kvlist_to_map(Keys, Tail,
|
||||||
maps:put(Atom, [Value, MapValue], Map));
|
Map#{Atom => [Value, MapValue]});
|
||||||
error ->
|
error ->
|
||||||
kvlist_to_map(Keys, Tail,
|
kvlist_to_map(Keys, Tail,
|
||||||
maps:put(Atom, Value, Map))
|
Map#{Atom => Value})
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
kvlist_to_map(Keys, Tail, Map)
|
kvlist_to_map(Keys, Tail, Map)
|
||||||
|
@ -1221,7 +1221,7 @@ filter([{Key, Constraints, Default}|Tail], Map) ->
|
||||||
{ok, Value} ->
|
{ok, Value} ->
|
||||||
filter_constraints(Tail, Map, Key, Value, Constraints);
|
filter_constraints(Tail, Map, Key, Value, Constraints);
|
||||||
error ->
|
error ->
|
||||||
filter(Tail, maps:put(Key, Default, Map))
|
filter(Tail, Map#{Key => Default})
|
||||||
end;
|
end;
|
||||||
filter([Key|Tail], Map) ->
|
filter([Key|Tail], Map) ->
|
||||||
true = maps:is_key(Key, Map),
|
true = maps:is_key(Key, Map),
|
||||||
|
@ -1232,7 +1232,7 @@ filter_constraints(Tail, Map, Key, Value, Constraints) ->
|
||||||
true ->
|
true ->
|
||||||
filter(Tail, Map);
|
filter(Tail, Map);
|
||||||
{true, Value2} ->
|
{true, Value2} ->
|
||||||
filter(Tail, maps:put(Key, Value2, Map))
|
filter(Tail, Map#{Key => Value2})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Tests.
|
%% Tests.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue