Skip to content

Commit c74ae70

Browse files
Merge pull request #14065 from rabbitmq/mergify/bp/v4.1.x/pr-14060
Avoid using the size/1 BIF (backport #14060)
2 parents f7a6f4e + cf6a4fb commit c74ae70

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

deps/amqp10_client/src/amqp10_client_frame_reader.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ handle_input(expecting_frame_body, Data,
253253
handle_input(expecting_frame_header, Rest, State);
254254
{<<Body:BodyLength/binary, Rest/binary>>, _} ->
255255
State1 = State#state{frame_state = undefined},
256-
BytesBody = size(Body),
256+
BytesBody = byte_size(Body),
257257
{DescribedPerformative, BytesParsed} = amqp10_binary_parser:parse(Body),
258258
Performative = amqp10_framing:decode(DescribedPerformative),
259259
Payload = if BytesParsed < BytesBody ->

deps/amqp10_client/src/amqp10_client_session.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ decode_as_msg(Transfer, Payload, undefined) ->
11801180
Sections = amqp10_framing:decode_bin(Payload),
11811181
{ok, amqp10_msg:from_amqp_records([Transfer | Sections])};
11821182
decode_as_msg(Transfer, Payload, FooterOpt) ->
1183-
PosSections = decode_sections([], Payload, size(Payload), 0),
1183+
PosSections = decode_sections([], Payload, byte_size(Payload), 0),
11841184
Sections = lists:map(fun({_Pos, S}) -> S end, PosSections),
11851185
Msg = amqp10_msg:from_amqp_records([Transfer | Sections]),
11861186
OkMsg = {ok, Msg},

deps/amqp10_common/src/amqp10_binary_generator.erl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ generate1({char,V}) when V>=0 andalso V=<16#10ffff -> <<16#73,V:32>>;
120120
generate1({timestamp,V}) -> <<16#83,V:64/signed>>;
121121
generate1({uuid, V}) -> <<16#98,V:16/binary>>;
122122

123-
generate1({utf8, V}) when size(V) =< ?VAR_1_LIMIT -> [16#a1, size(V), V];
124-
generate1({utf8, V}) -> [<<16#b1, (size(V)):32>>, V];
125-
generate1({symbol, V}) when size(V) =< ?VAR_1_LIMIT -> [16#a3, size(V), V];
126-
generate1({symbol, V}) -> [<<16#b3, (size(V)):32>>, V];
123+
generate1({utf8, V})
124+
when byte_size(V) =< ?VAR_1_LIMIT -> [16#a1, byte_size(V), V];
125+
generate1({utf8, V}) -> [<<16#b1, (byte_size(V)):32>>, V];
126+
generate1({symbol, V})
127+
when byte_size(V) =< ?VAR_1_LIMIT -> [16#a3, byte_size(V), V];
128+
generate1({symbol, V}) -> [<<16#b3, (byte_size(V)):32>>, V];
127129
generate1({binary, V}) ->
128130
Size = iolist_size(V),
129131
case Size =< ?VAR_1_LIMIT of

deps/rabbit/src/rabbit_amqp_filtex.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ match_simple_type({suffix, SuffixSize, Suffix}, Val) ->
8888
case is_binary(Val) of
8989
true ->
9090
case Val of
91-
<<_:(size(Val) - SuffixSize)/binary, Suffix:SuffixSize/binary>> ->
91+
<<_:(byte_size(Val) - SuffixSize)/binary, Suffix:SuffixSize/binary>> ->
9292
true;
9393
_ ->
9494
false
@@ -187,9 +187,9 @@ validate_app_props(_, _) ->
187187

188188
%% [filtex-v1.0-wd09 4.1.1]
189189
parse_string_modifier_prefix(<<"&s:", Suffix/binary>>) ->
190-
{suffix, size(Suffix), Suffix};
190+
{suffix, byte_size(Suffix), Suffix};
191191
parse_string_modifier_prefix(<<"&p:", Prefix/binary>>) ->
192-
{prefix, size(Prefix), Prefix};
192+
{prefix, byte_size(Prefix), Prefix};
193193
parse_string_modifier_prefix(<<"&&", _/binary>> = String) ->
194194
%% "Escape prefix for case-sensitive matching of a string starting with ‘&’"
195195
string:slice(String, 1);

deps/rabbit/src/rabbit_amqp_reader.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mainloop(Deb, State = #v1{sock = Sock, buf = Buf, buf_len = BufLen}) ->
113113
{data, Data} ->
114114
State1 = maybe_resize_buffer(State, Data),
115115
recvloop(Deb, State1#v1{buf = [Data | Buf],
116-
buf_len = BufLen + size(Data),
116+
buf_len = BufLen + byte_size(Data),
117117
pending_recv = false});
118118
closed when State#v1.connection_state =:= closed ->
119119
ok;
@@ -403,7 +403,7 @@ handle_frame0(Mode, Channel, Body, State) ->
403403

404404
%% "The frame body is defined as a performative followed by an opaque payload." [2.3.2]
405405
parse_frame_body(Body, _Channel) ->
406-
BytesBody = size(Body),
406+
BytesBody = byte_size(Body),
407407
{DescribedPerformative, BytesParsed} = amqp10_binary_parser:parse(Body),
408408
Performative = amqp10_framing:decode(DescribedPerformative),
409409
if BytesParsed < BytesBody ->

deps/rabbit/src/rabbit_queue_index.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ publish(MsgOrId, SeqId, _Location, MsgProps, IsPersistent, JournalSizeHint, Stat
418418
false -> ?PUB_TRANS_JPREFIX
419419
end):?JPREFIX_BITS,
420420
SeqId:?SEQ_BITS, Bin/binary,
421-
(size(MsgBin)):?EMBEDDED_SIZE_BITS>>, MsgBin]),
421+
(byte_size(MsgBin)):?EMBEDDED_SIZE_BITS>>, MsgBin]),
422422
maybe_flush_journal(
423423
JournalSizeHint,
424424
add_to_journal(SeqId, {IsPersistent, Bin, MsgBin}, State1)).
@@ -434,7 +434,7 @@ maybe_needs_confirming(MsgProps, MsgOrId,
434434
Msg ->
435435
mc:get_annotation(id, Msg)
436436
end,
437-
?MSG_ID_BYTES = size(MsgId),
437+
?MSG_ID_BYTES = byte_size(MsgId),
438438
case {MsgProps#message_properties.needs_confirming, MsgOrId} of
439439
{true, MsgId} -> UC1 = sets:add_element(MsgId, UC),
440440
State#qistate{unconfirmed = UC1};

0 commit comments

Comments
 (0)