[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Wed Nov 2 13:22:02 UTC 2016
loolwsd/DocumentBroker.cpp | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
New commits:
commit 05d4234208df0777ea8d8da9dceda200222d5a58
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Oct 31 21:25:19 2016 -0400
loolwsd: more efficient client message forwarding
Change-Id: I10f880059380599cf0187064e1009bef5fa693b1
Reviewed-on: https://gerrit.libreoffice.org/30492
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 5f417f1..a332af6 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -851,8 +851,21 @@ bool DocumentBroker::forwardToChild(const std::string& viewId, const std::string
bool DocumentBroker::forwardToClient(const std::string& prefix, const std::vector<char>& payload)
{
- std::string message(payload.data() + prefix.size(), payload.size() - prefix.size());
- Util::ltrim(message);
+ assert(payload.size() > prefix.size());
+
+ // Remove the prefix and trim.
+ size_t index = prefix.size();
+ for ( ; index < payload.size(); ++index)
+ {
+ if (payload[index] != ' ')
+ {
+ break;
+ }
+ }
+
+ auto data = payload.data() + index;
+ auto size = payload.size() - index;
+ const auto message = getAbbreviatedMessage(data, size);
Log::trace("Forwarding payload to " + prefix + ' ' + message);
std::string name;
@@ -865,7 +878,7 @@ bool DocumentBroker::forwardToClient(const std::string& prefix, const std::vecto
const auto peer = it->second->getPeer();
if (peer)
{
- return peer->handleInput(message.data(), message.size());
+ return peer->handleInput(data, size);
}
else
{
More information about the Libreoffice-commits
mailing list