Skip to content

Commit a3ec7c5

Browse files
authored
Use binary concatenation for segment filenames (#10628)
1 parent 8ba7e9b commit a3ec7c5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

deps/rabbit/src/rabbit_classic_queue_index_v2.erl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ init_for_conversion(#resource{ virtual_host = VHost } = Name, OnSyncFun, OnSyncM
196196

197197
init1(Name, Dir, OnSyncFun, OnSyncMsgFun) ->
198198
ensure_queue_name_stub_file(Name, Dir),
199+
DirBin = rabbit_file:filename_to_binary(Dir),
199200
#qi{
200201
queue_name = Name,
201-
dir = rabbit_file:filename_to_binary(Dir),
202+
dir = << DirBin/binary, "/" >>,
202203
on_sync = OnSyncFun,
203204
on_sync_msg = OnSyncMsgFun
204205
}.
@@ -1277,8 +1278,8 @@ queue_name_to_dir_name(#resource { kind = queue,
12771278
rabbit_misc:format("~.36B", [Num]).
12781279

12791280
segment_file(Segment, #qi{ dir = Dir }) ->
1280-
filename:join(rabbit_file:binary_to_filename(Dir),
1281-
integer_to_list(Segment) ++ ?SEGMENT_EXTENSION).
1281+
N = integer_to_binary(Segment),
1282+
<<Dir/binary, N/binary, ?SEGMENT_EXTENSION>>.
12821283

12831284
highest_continuous_seq_id([SeqId|Tail], EndSeqId)
12841285
when (1 + SeqId) =:= EndSeqId ->

deps/rabbit/src/rabbit_classic_queue_store_v2.erl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ init(#resource{ virtual_host = VHost } = Name) ->
118118
?DEBUG("~0p", [Name]),
119119
VHostDir = rabbit_vhost:msg_store_dir_path(VHost),
120120
Dir = rabbit_classic_queue_index_v2:queue_dir(VHostDir, Name),
121-
#qs{dir = rabbit_file:filename_to_binary(Dir)}.
121+
DirBin = rabbit_file:filename_to_binary(Dir),
122+
#qs{dir = << DirBin/binary, "/" >>}.
122123

123124
-spec terminate(State) -> State when State::state().
124125

@@ -570,6 +571,6 @@ check_crc32() ->
570571

571572
%% Same implementation as rabbit_classic_queue_index_v2:segment_file/2,
572573
%% but with a different state record.
573-
segment_file(Segment, #qs{ dir = Dir }) ->
574-
filename:join(rabbit_file:binary_to_filename(Dir),
575-
integer_to_list(Segment) ++ ?SEGMENT_EXTENSION).
574+
segment_file(Segment, #qs{dir = Dir}) ->
575+
N = integer_to_binary(Segment),
576+
<<Dir/binary, N/binary, ?SEGMENT_EXTENSION>>.

0 commit comments

Comments
 (0)