Skip to content

Commit 8a0c03a

Browse files
committed
Optimize with std::move to avoid all possible copies
1 parent 219f0de commit 8a0c03a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

MessageControl/MessageOutput.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace Publishers {
149149
_adminLock.Unlock();
150150
}
151151
else {
152-
const string msg = _queue.front();
152+
string msg = std::move(_queue.front());
153153
_queue.pop();
154154
_adminLock.Unlock();
155155

@@ -169,11 +169,11 @@ namespace Publishers {
169169
{
170170
}
171171

172-
void UDPOutput::Channel::Output(const string& text)
172+
void UDPOutput::Channel::Output(string&& text)
173173
{
174174
_adminLock.Lock();
175175

176-
_queue.push(text);
176+
_queue.emplace(std::move(text));
177177

178178
_adminLock.Unlock();
179179

MessageControl/MessageOutput.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ namespace Publishers {
354354
explicit Channel(const Core::NodeId& nodeId);
355355
~Channel() override;
356356

357-
void Output(const string& text);
357+
void Output(string&& text);
358358

359359
private:
360360
uint16_t SendData(uint8_t* dataFrame, const uint16_t maxSendSize) override;

0 commit comments

Comments
 (0)