From 9e1fc3ca1efd9ad313ad904c956817c615b51df1 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sun, 12 Jun 2022 21:00:17 -0400 Subject: [PATCH] Arguments to synchronous (blocking) methods should be passed by const-ref instead of by val. --- src/stream_outlet_impl.cpp | 6 +++--- src/stream_outlet_impl.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/stream_outlet_impl.cpp b/src/stream_outlet_impl.cpp index 2206c6c9..e00c8a0c 100644 --- a/src/stream_outlet_impl.cpp +++ b/src/stream_outlet_impl.cpp @@ -172,7 +172,7 @@ bool stream_outlet_impl::wait_for_consumers(double timeout) { return send_buffer_->wait_for_consumers(timeout); } -void stream_outlet_impl::push_timestamp_sync(double timestamp) { +void stream_outlet_impl::push_timestamp_sync(const double& timestamp) { static_assert(TAG_TRANSMITTED_TIMESTAMP == 2, "Unexpected TAG_TRANSMITTED_TIMESTAMP"); const uint64_t ENDIAN_SAFE_TAG_TRANSMITTED = (2LL << 28) | 2LL; if (timestamp == DEDUCED_TIMESTAMP) { @@ -193,7 +193,7 @@ void stream_outlet_impl::pushthrough_sync() { } void stream_outlet_impl::enqueue_sync( - asio::const_buffer buff, double timestamp, bool pushthrough) { + asio::const_buffer buff, const double& timestamp, bool pushthrough) { push_timestamp_sync(timestamp); sync_buffs_.push_back(buff); if (pushthrough) pushthrough_sync(); @@ -221,7 +221,7 @@ template void stream_outlet_impl::enqueue(const double *data, double, bo template void stream_outlet_impl::enqueue(const std::string *data, double, bool); void stream_outlet_impl::enqueue_sync_multi( - std::vector buffs, double timestamp, bool pushthrough) { + std::vector buffs, const double& timestamp, bool pushthrough) { push_timestamp_sync(timestamp); sync_buffs_.insert(sync_buffs_.end(), buffs.begin(), buffs.end()); if (pushthrough) pushthrough_sync(); diff --git a/src/stream_outlet_impl.h b/src/stream_outlet_impl.h index 0d772bdb..54d6c118 100644 --- a/src/stream_outlet_impl.h +++ b/src/stream_outlet_impl.h @@ -310,14 +310,14 @@ class stream_outlet_impl { /// Append the appropriate timestamp tag and optionally timestamp onto sync_buffs_ for a single /// timestamp. - void push_timestamp_sync(double timestamp); + void push_timestamp_sync(const double& timestamp); /// push sync_buffs_ through each tcp server. void pushthrough_sync(); /// Append a single timestamp and single buffer to sync_buffs and optionally pushthrough the /// server. - void enqueue_sync(asio::const_buffer buff, double timestamp, bool pushthrough); + void enqueue_sync(asio::const_buffer buff, const double& timestamp, bool pushthrough); /** * Append a single timestamp and multiple within-sample buffers to sync_buffs_. @@ -325,7 +325,7 @@ class stream_outlet_impl { * many channels are included in each buffer. */ void enqueue_sync_multi( - std::vector buffs, double timestamp, bool pushthrough); + std::vector buffs, const double& timestamp, bool pushthrough); /** * Check whether some given number of channels matches the stream's channel_count.