Skip to content

Commit f7e2e00

Browse files
committed
[fix][Fec base] missing & to avoid copying object
1 parent ef40e24 commit f7e2e00

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/fec_base.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ class FecCode {
174174
bool readw(T* ptr, std::istream* stream);
175175
bool writew(T val, std::ostream* stream);
176176

177-
bool read_pkt(char* pkt, std::istream& stream);
178-
bool write_pkt(char* pkt, std::ostream& stream, size_t bytes);
177+
bool read_pkt(char* pkt, std::istream* stream);
178+
bool write_pkt(char* pkt, std::ostream* stream, size_t bytes);
179179

180180
void encode_streams_horizontal(
181181
std::vector<std::istream*> input_data_bufs,
@@ -390,15 +390,15 @@ inline bool FecCode<T>::writew(T val, std::ostream* stream)
390390
}
391391

392392
template <typename T>
393-
inline bool FecCode<T>::read_pkt(char* pkt, std::istream& stream)
393+
inline bool FecCode<T>::read_pkt(char* pkt, std::istream* stream)
394394
{
395-
return static_cast<bool>(stream.read(pkt, buf_size));
395+
return static_cast<bool>(stream->read(pkt, buf_size));
396396
}
397397

398398
template <typename T>
399-
inline bool FecCode<T>::write_pkt(char* pkt, std::ostream& stream, size_t bytes)
399+
inline bool FecCode<T>::write_pkt(char* pkt, std::ostream* stream, size_t bytes)
400400
{
401-
return static_cast<bool>(stream.write(pkt, bytes));
401+
return static_cast<bool>(stream->write(pkt, bytes));
402402
}
403403

404404
/** Encode streams
@@ -485,13 +485,13 @@ void FecCode<T>::encode_streams_vertical(
485485

486486
// vector of buffers storing data that are performed in encoding, i.e. FFT
487487
vec::Buffers<T> words(n_data, pkt_size, use_meta_buf);
488-
std::vector<T*> words_mem = words.get_mem();
488+
const std::vector<T*>& words_mem = words.get_mem();
489489

490490
int output_len = get_n_outputs();
491491

492492
// vector of buffers storing data that are performed in encoding, i.e. FFT
493493
vec::Buffers<T> output(output_len, pkt_size, use_meta_buf);
494-
const std::vector<T*> output_mem = output.get_mem();
494+
const std::vector<T*>& output_mem = output.get_mem();
495495

496496
reset_stats_enc();
497497

@@ -503,7 +503,7 @@ void FecCode<T>::encode_streams_vertical(
503503
for (unsigned i = 0; i < n_data; i++) {
504504
if (!read_pkt(
505505
reinterpret_cast<char*>(words_mem.at(i)),
506-
*(input_data_bufs[i]))) {
506+
input_data_bufs[i])) {
507507
read_bytes = input_data_bufs[i]->gcount();
508508
// Zero-out trailing part
509509
std::fill_n(
@@ -536,7 +536,7 @@ void FecCode<T>::encode_streams_vertical(
536536
for (unsigned i = 0; i < n_outputs; i++) {
537537
write_pkt(
538538
reinterpret_cast<char*>(output_mem.at(i)),
539-
*(output_parities_bufs[i]),
539+
output_parities_bufs[i],
540540
read_bytes);
541541
}
542542
offset += pkt_size;
@@ -972,13 +972,13 @@ bool FecCode<T>::decode_streams_vertical(
972972

973973
// vector of buffers storing data that are performed in encoding, i.e. FFT
974974
vec::Buffers<T> words(n_data, pkt_size, use_meta_buf);
975-
const std::vector<T*> words_mem = words.get_mem();
975+
const std::vector<T*>& words_mem = words.get_mem();
976976

977977
int output_len = n_data;
978978

979979
// vector of buffers storing data that are performed in decoding, i.e. FFT
980980
vec::Buffers<T> output(output_len, pkt_size, use_meta_buf);
981-
const std::vector<T*> output_mem = output.get_mem();
981+
const std::vector<T*>& output_mem = output.get_mem();
982982

983983
std::unique_ptr<DecodeContext<T>> context = init_context_dec(
984984
fragments_ids, input_parities_props, pkt_size, &output);
@@ -995,7 +995,7 @@ bool FecCode<T>::decode_streams_vertical(
995995
unsigned data_idx = fragments_ids.get(i);
996996
if (!read_pkt(
997997
reinterpret_cast<char*>(words_mem.at(i)),
998-
*(input_data_bufs[data_idx]))) {
998+
input_data_bufs[data_idx])) {
999999
read_bytes = input_data_bufs[data_idx]->gcount();
10001000
// Zero-out trailing part
10011001
std::fill_n(
@@ -1011,7 +1011,7 @@ bool FecCode<T>::decode_streams_vertical(
10111011
unsigned parity_idx = avail_parity_ids.get(i);
10121012
if (!read_pkt(
10131013
reinterpret_cast<char*>(words_mem.at(avail_data_nb + i)),
1014-
*(input_parities_bufs[parity_idx]))) {
1014+
input_parities_bufs[parity_idx])) {
10151015
read_bytes = input_parities_bufs[parity_idx]->gcount();
10161016
// Zero-out trailing part
10171017
std::fill_n(
@@ -1046,7 +1046,7 @@ bool FecCode<T>::decode_streams_vertical(
10461046
if (output_data_bufs[i] != nullptr) {
10471047
write_pkt(
10481048
reinterpret_cast<char*>(output_mem.at(i)),
1049-
*(output_data_bufs[i]),
1049+
output_data_bufs[i],
10501050
read_bytes);
10511051
}
10521052
}
@@ -1094,13 +1094,13 @@ void FecCode<T>::encode_blocks_vertical(
10941094

10951095
// vector of buffers storing data that are performed in encoding, i.e. FFT
10961096
vec::Buffers<T> words(n_data, pkt_size, use_meta_buf);
1097-
const std::vector<T*> words_mem = words.get_mem();
1097+
const std::vector<T*>& words_mem = words.get_mem();
10981098

10991099
int output_len = get_n_outputs();
11001100

11011101
// vector of buffers storing data that are performed in encoding, i.e. FFT
11021102
vec::Buffers<T> output(output_len, pkt_size, use_meta_buf);
1103-
const std::vector<T*> output_mem = output.get_mem();
1103+
const std::vector<T*>& output_mem = output.get_mem();
11041104

11051105
reset_stats_enc();
11061106

@@ -1242,13 +1242,13 @@ bool FecCode<T>::decode_blocks_vertical(
12421242

12431243
// vector of buffers storing data that are performed in encoding, i.e. FFT
12441244
vec::Buffers<T> words(n_data, pkt_size, use_meta_buf);
1245-
const std::vector<T*> words_mem = words.get_mem();
1245+
const std::vector<T*>& words_mem = words.get_mem();
12461246

12471247
int output_len = n_data;
12481248

12491249
// vector of buffers storing data that are performed in decoding, i.e. FFT
12501250
vec::Buffers<T> output(output_len, pkt_size, use_meta_buf);
1251-
const std::vector<T*> output_mem = output.get_mem();
1251+
const std::vector<T*>& output_mem = output.get_mem();
12521252

12531253
std::unique_ptr<DecodeContext<T>> context =
12541254
init_context_dec(fragments_ids, parities_props, pkt_size, &output);

0 commit comments

Comments
 (0)