From f49a3485127010ca26672a29ced5e94ee8b992a0 Mon Sep 17 00:00:00 2001 From: jrsala-auguration <96196256+jrsala-auguration@users.noreply.github.com> Date: Wed, 1 Mar 2023 10:57:26 +0000 Subject: [PATCH] [C++] std::forward fragment handlers to avoid unnecessary copies (#1405) Co-authored-by: Joan-Roch Sala --- aeron-client/src/main/cpp/Image.h | 2 +- aeron-client/src/main/cpp/Subscription.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aeron-client/src/main/cpp/Image.h b/aeron-client/src/main/cpp/Image.h index a3b73dcb9f..bbad481a47 100644 --- a/aeron-client/src/main/cpp/Image.h +++ b/aeron-client/src/main/cpp/Image.h @@ -404,7 +404,7 @@ class Image AtomicBuffer &termBuffer = m_termBuffers[index]; TermReader::ReadOutcome outcome{}; - TermReader::read(outcome, termBuffer, offset, fragmentHandler, fragmentLimit, m_header, m_exceptionHandler); + TermReader::read(outcome, termBuffer, offset, std::forward(fragmentHandler), fragmentLimit, m_header, m_exceptionHandler); const std::int64_t newPosition = position + (outcome.offset - offset); if (newPosition > position) diff --git a/aeron-client/src/main/cpp/Subscription.h b/aeron-client/src/main/cpp/Subscription.h index 4bda5de3a7..5fffc44b3e 100644 --- a/aeron-client/src/main/cpp/Subscription.h +++ b/aeron-client/src/main/cpp/Subscription.h @@ -221,12 +221,12 @@ class CLIENT_EXPORT Subscription for (std::size_t i = startingIndex; i < length && fragmentsRead < fragmentLimit; i++) { - fragmentsRead += imageArray[i]->poll(fragmentHandler, fragmentLimit - fragmentsRead); + fragmentsRead += imageArray[i]->poll(std::forward(fragmentHandler), fragmentLimit - fragmentsRead); } for (std::size_t i = 0; i < startingIndex && fragmentsRead < fragmentLimit; i++) { - fragmentsRead += imageArray[i]->poll(fragmentHandler, fragmentLimit - fragmentsRead); + fragmentsRead += imageArray[i]->poll(std::forward(fragmentHandler), fragmentLimit - fragmentsRead); } return fragmentsRead; @@ -263,12 +263,12 @@ class CLIENT_EXPORT Subscription for (std::size_t i = startingIndex; i < length && fragmentsRead < fragmentLimit; i++) { - fragmentsRead += imageArray[i]->controlledPoll(fragmentHandler, fragmentLimit - fragmentsRead); + fragmentsRead += imageArray[i]->controlledPoll(std::forward(fragmentHandler), fragmentLimit - fragmentsRead); } for (std::size_t i = 0; i < startingIndex && fragmentsRead < fragmentLimit; i++) { - fragmentsRead += imageArray[i]->controlledPoll(fragmentHandler, fragmentLimit - fragmentsRead); + fragmentsRead += imageArray[i]->controlledPoll(std::forward(fragmentHandler), fragmentLimit - fragmentsRead); } return fragmentsRead; @@ -291,7 +291,7 @@ class CLIENT_EXPORT Subscription for (std::size_t i = 0; i < length; i++) { - bytesConsumed += imageArray[i]->blockPoll(blockHandler, blockLengthLimit); + bytesConsumed += imageArray[i]->blockPoll(std::forward(blockHandler), blockLengthLimit); } return bytesConsumed;