Skip to content

Commit 9e1fc3c

Browse files
committed
Arguments to synchronous (blocking) methods should be passed by const-ref instead of by val.
1 parent ba1acba commit 9e1fc3c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/stream_outlet_impl.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ bool stream_outlet_impl::wait_for_consumers(double timeout) {
172172
return send_buffer_->wait_for_consumers(timeout);
173173
}
174174

175-
void stream_outlet_impl::push_timestamp_sync(double timestamp) {
175+
void stream_outlet_impl::push_timestamp_sync(const double& timestamp) {
176176
static_assert(TAG_TRANSMITTED_TIMESTAMP == 2, "Unexpected TAG_TRANSMITTED_TIMESTAMP");
177177
const uint64_t ENDIAN_SAFE_TAG_TRANSMITTED = (2LL << 28) | 2LL;
178178
if (timestamp == DEDUCED_TIMESTAMP) {
@@ -193,7 +193,7 @@ void stream_outlet_impl::pushthrough_sync() {
193193
}
194194

195195
void stream_outlet_impl::enqueue_sync(
196-
asio::const_buffer buff, double timestamp, bool pushthrough) {
196+
asio::const_buffer buff, const double& timestamp, bool pushthrough) {
197197
push_timestamp_sync(timestamp);
198198
sync_buffs_.push_back(buff);
199199
if (pushthrough) pushthrough_sync();
@@ -221,7 +221,7 @@ template void stream_outlet_impl::enqueue<double>(const double *data, double, bo
221221
template void stream_outlet_impl::enqueue<std::string>(const std::string *data, double, bool);
222222

223223
void stream_outlet_impl::enqueue_sync_multi(
224-
std::vector<asio::const_buffer> buffs, double timestamp, bool pushthrough) {
224+
std::vector<asio::const_buffer> buffs, const double& timestamp, bool pushthrough) {
225225
push_timestamp_sync(timestamp);
226226
sync_buffs_.insert(sync_buffs_.end(), buffs.begin(), buffs.end());
227227
if (pushthrough) pushthrough_sync();

src/stream_outlet_impl.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -310,22 +310,22 @@ class stream_outlet_impl {
310310

311311
/// Append the appropriate timestamp tag and optionally timestamp onto sync_buffs_ for a single
312312
/// timestamp.
313-
void push_timestamp_sync(double timestamp);
313+
void push_timestamp_sync(const double& timestamp);
314314

315315
/// push sync_buffs_ through each tcp server.
316316
void pushthrough_sync();
317317

318318
/// Append a single timestamp and single buffer to sync_buffs and optionally pushthrough the
319319
/// server.
320-
void enqueue_sync(asio::const_buffer buff, double timestamp, bool pushthrough);
320+
void enqueue_sync(asio::const_buffer buff, const double& timestamp, bool pushthrough);
321321

322322
/**
323323
* Append a single timestamp and multiple within-sample buffers to sync_buffs_.
324324
* This is useful when a sample is discontiguous in memory. It makes no assumptions about how
325325
* many channels are included in each buffer.
326326
*/
327327
void enqueue_sync_multi(
328-
std::vector<asio::const_buffer> buffs, double timestamp, bool pushthrough);
328+
std::vector<asio::const_buffer> buffs, const double& timestamp, bool pushthrough);
329329

330330
/**
331331
* Check whether some given number of channels matches the stream's channel_count.

0 commit comments

Comments
 (0)