summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-05-11 12:33:24 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-05-11 12:33:24 +0200
commit74631b092e165d40f7f7c6fcff1ac60aa73854e0 (patch)
tree3197d4d266be3433aecf9380ccc5a7f53a9b0072
parent0f618a42ea03e93c2a42b272aabdcda275b10a09 (diff)
downloadrabbitmq-server-git-74631b092e165d40f7f7c6fcff1ac60aa73854e0.tar.gz
rabbit_definitions: Use maps:update_with/4 directly
... instead of using a copy of the function from Erlang 20. This is possible because the requirement was bumped to Erlang 21. Reported by Dialyzer.
-rw-r--r--src/rabbit_definitions.erl15
1 files changed, 1 insertions, 14 deletions
diff --git a/src/rabbit_definitions.erl b/src/rabbit_definitions.erl
index 234ed122d0..68b0df600c 100644
--- a/src/rabbit_definitions.erl
+++ b/src/rabbit_definitions.erl
@@ -597,25 +597,12 @@ build_filtered_map([Queue|Rest], AccMap0) ->
{Rec, VHost} = build_queue_data(Queue),
case rabbit_amqqueue:lookup(Rec) of
{error, not_found} ->
- AccMap1 = maps_update_with(VHost, fun(V) -> V + 1 end, 1, AccMap0),
+ AccMap1 = maps:update_with(VHost, fun(V) -> V + 1 end, 1, AccMap0),
build_filtered_map(Rest, AccMap1);
{ok, _} ->
build_filtered_map(Rest, AccMap0)
end.
-%% Copy of maps:with_util/3 from Erlang 20.0.1.
-maps_update_with(Key,Fun,Init,Map) when is_function(Fun,1), is_map(Map) ->
- case maps:find(Key,Map) of
- {ok,Val} -> maps:update(Key,Fun(Val),Map);
- error -> maps:put(Key,Init,Map)
- end;
-maps_update_with(Key,Fun,Init,Map) ->
- erlang:error(maps_error_type(Map),[Key,Fun,Init,Map]).
-
-%% Copy of maps:error_type/1 from Erlang 20.0.1.
-maps_error_type(M) when is_map(M) -> badarg;
-maps_error_type(V) -> {badmap, V}.
-
validate_vhost_limit(VHost, AddCount, ok) ->
WouldExceed = rabbit_vhost_limit:would_exceed_queue_limit(AddCount, VHost),
validate_vhost_queue_limit(VHost, AddCount, WouldExceed).