From 6c2d20353a80c74c5371c40baf76b95a5a86e93b Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 28 Mar 2018 13:59:33 -0700 Subject: [PATCH] minor, avoid extra string copys --- src/remote/channelSearchManager.cpp | 2 +- src/remote/pv/channelSearchManager.h | 4 ++-- src/remoteClient/clientContextImpl.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/remote/channelSearchManager.cpp b/src/remote/channelSearchManager.cpp index cfb342b..c5aaeda 100644 --- a/src/remote/channelSearchManager.cpp +++ b/src/remote/channelSearchManager.cpp @@ -258,7 +258,7 @@ bool ChannelSearchManager::generateSearchRequestMessage(SearchInstance::shared_p return false; */ - const std::string name = channel->getSearchInstanceName(); + const std::string& name(channel->getSearchInstanceName()); // not nice... const int addedPayloadSize = sizeof(int32)/sizeof(int8) + (1 + sizeof(int32)/sizeof(int8) + name.length()); if(((int)requestMessage->getRemaining()) < addedPayloadSize) diff --git a/src/remote/pv/channelSearchManager.h b/src/remote/pv/channelSearchManager.h index 5e4d850..43b53f9 100644 --- a/src/remote/pv/channelSearchManager.h +++ b/src/remote/pv/channelSearchManager.h @@ -32,11 +32,11 @@ public: /** * Destructor */ - virtual ~SearchInstance() {}; + virtual ~SearchInstance() {} virtual pvAccessID getSearchInstanceID() = 0; - virtual std::string getSearchInstanceName() = 0; + virtual const std::string& getSearchInstanceName() = 0; virtual int32_t& getUserValue() = 0; diff --git a/src/remoteClient/clientContextImpl.cpp b/src/remoteClient/clientContextImpl.cpp index 0afeea0..9c03dc5 100644 --- a/src/remoteClient/clientContextImpl.cpp +++ b/src/remoteClient/clientContextImpl.cpp @@ -3355,7 +3355,7 @@ public: return m_channelID; } - virtual string getSearchInstanceName() OVERRIDE FINAL { + virtual const string& getSearchInstanceName() OVERRIDE FINAL { return m_name; }