Skip to content

Commit 0184aa9

Browse files
committed
Build map more efficiently
Call maps:from_list/1 once instead of iteratively adding key/value associations to the map. (cherry picked from commit 314ff38)
1 parent 83ee59c commit 0184aa9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

deps/rabbit/src/rabbit_amqp_session.erl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,21 +1886,20 @@ settle_op_from_outcome(#'v1_0.released'{}) ->
18861886
%% See https://github.com/rabbitmq/rabbitmq-server/issues/6121
18871887
settle_op_from_outcome(#'v1_0.modified'{delivery_failed = DelFailed,
18881888
undeliverable_here = UndelHere,
1889-
message_annotations = Anns0
1890-
}) ->
1889+
message_annotations = Anns0}) ->
18911890
Anns = case Anns0 of
18921891
#'v1_0.message_annotations'{content = C} ->
1893-
C;
1892+
Anns1 = lists:map(fun({{symbol, K}, V}) ->
1893+
{K, unwrap(V)}
1894+
end, C),
1895+
maps:from_list(Anns1);
18941896
_ ->
1895-
[]
1897+
#{}
18961898
end,
18971899
{modify,
18981900
default(DelFailed, false),
18991901
default(UndelHere, false),
1900-
%% TODO: this must exist elsewhere
1901-
lists:foldl(fun ({{symbol, K}, V}, Acc) ->
1902-
Acc#{K => unwrap(V)}
1903-
end, #{}, Anns)};
1902+
Anns};
19041903
settle_op_from_outcome(Outcome) ->
19051904
protocol_error(
19061905
?V_1_0_AMQP_ERROR_INVALID_FIELD,

0 commit comments

Comments
 (0)