[Libreoffice-commits] online.git: common/Rectangle.hpp common/Util.hpp kit/Kit.cpp wsd/Admin.cpp wsd/Admin.hpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/LOOLWSD.cpp wsd/ProxyProtocol.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 2 18:02:02 UTC 2020
common/Rectangle.hpp | 1 +
common/Util.hpp | 5 ++---
kit/Kit.cpp | 3 ++-
wsd/Admin.cpp | 2 +-
wsd/Admin.hpp | 2 +-
wsd/ClientSession.cpp | 4 ++--
wsd/ClientSession.hpp | 2 +-
wsd/LOOLWSD.cpp | 3 ++-
wsd/ProxyProtocol.cpp | 6 +++---
9 files changed, 15 insertions(+), 13 deletions(-)
New commits:
commit 4a8937d0d1a2665f3700c4ea14d5f70e844b7064
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Tue Jun 2 03:44:08 2020 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Jun 2 20:01:39 2020 +0200
wsd: performance improvements
Change-Id: I137dc67b4231df1cd23a9dce72e6b12dc1bf364e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95343
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/common/Rectangle.hpp b/common/Rectangle.hpp
index 3e73bc251..0869d207f 100644
--- a/common/Rectangle.hpp
+++ b/common/Rectangle.hpp
@@ -9,6 +9,7 @@
#pragma once
+#include <algorithm> // std::min, std::max
#include <limits>
namespace Util
diff --git a/common/Util.hpp b/common/Util.hpp
index d41f81319..fed1525e6 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -382,9 +382,8 @@ namespace Util
return false;
}
- /// Tokenize space-delimited values until we hit new-line or the end.
- template <typename T>
- inline void tokenize(const char* data, const std::size_t size, const T& delimiter,
+ /// Tokenize delimited values until we hit new-line or the end.
+ inline void tokenize(const char* data, const std::size_t size, const char delimiter,
std::vector<StringToken>& tokens)
{
if (size == 0 || data == nullptr || *data == '\0')
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 9fbc658b4..743251fef 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -69,6 +69,7 @@
#if !MOBILEAPP
#include <common/SigUtil.hpp>
#include <common/Seccomp.hpp>
+#include <utility>
#endif
#ifdef FUZZER
@@ -2226,7 +2227,7 @@ public:
void setDocument(std::shared_ptr<Document> document)
{
- _document = document;
+ _document = std::move(document);
}
};
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 3f48a0d8a..8d85dfbc7 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -602,7 +602,7 @@ std::string Admin::getChannelLogLevels()
return result;
}
-void Admin::setChannelLogLevel(std::string _channelName, std::string _level)
+void Admin::setChannelLogLevel(const std::string& _channelName, std::string _level)
{
assertCorrectThread();
diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp
index ae3967e06..42e7a247a 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -107,7 +107,7 @@ public:
std::string getChannelLogLevels();
- void setChannelLogLevel(std::string _channelName, std::string _level);
+ void setChannelLogLevel(const std::string& _channelName, std::string _level);
std::string getLogLines();
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index d164a0d45..d534a2656 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1034,7 +1034,7 @@ void ClientSession::writeQueuedMessages()
}
// NB. also see loleaflet/src/map/Clipboard.js that does this in JS for stubs.
-void ClientSession::postProcessCopyPayload(std::shared_ptr<Message> payload)
+void ClientSession::postProcessCopyPayload(const std::shared_ptr<Message>& payload)
{
// Insert our meta origin if we can
payload->rewriteDataBody([=](std::vector<char>& data) {
@@ -1359,7 +1359,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
LOOLWSD::SavedClipboards->insertClipboard(
_clipboardKeys, &payload->data()[header], payload->size() - header);
- for (auto it : _clipSockets)
+ for (const auto& it : _clipSockets)
{
std::ostringstream oss;
oss << "HTTP/1.1 200 OK\r\n"
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index c7d4e66ed..6103d0550 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -163,7 +163,7 @@ public:
std::string getClipboardURI(bool encode = true);
/// Adds and/or modified the copied payload before sending on to the client.
- void postProcessCopyPayload(std::shared_ptr<Message> payload);
+ void postProcessCopyPayload(const std::shared_ptr<Message>& payload);
/// Returns true if we're expired waiting for a clipboard and should be removed
bool staleWaitDisconnect(const std::chrono::steady_clock::time_point &now);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2b6bb013e..917ef33fb 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2567,7 +2567,7 @@ private:
Poco::URI requestUri(request.getURI());
Poco::URI::QueryParameters params = requestUri.getQueryParameters();
std::string WOPISrc, serverId, viewId, tag, mime;
- for (auto it : params)
+ for (const auto& it : params)
{
if (it.first == "WOPISrc")
WOPISrc = it.second;
@@ -3937,6 +3937,7 @@ std::vector<std::shared_ptr<DocumentBroker>> LOOLWSD::getBrokersTestOnly()
std::lock_guard<std::mutex> docBrokersLock(DocBrokersMutex);
std::vector<std::shared_ptr<DocumentBroker>> result;
+ result.reserve(DocBrokers.size());
for (auto& brokerIt : DocBrokers)
result.push_back(brokerIt.second);
return result;
diff --git a/wsd/ProxyProtocol.cpp b/wsd/ProxyProtocol.cpp
index 84b56b94b..a2b2c75b9 100644
--- a/wsd/ProxyProtocol.cpp
+++ b/wsd/ProxyProtocol.cpp
@@ -292,7 +292,7 @@ void ProxyProtocolHandler::dumpState(std::ostream& os)
os << '#' << (sock ? sock->getFD() : -2) << ' ';
}
os << '\n';
- for (auto it : _writeQueue)
+ for (const auto& it : _writeQueue)
Util::dumpHex(os, "\twrite queue entry:", "\t\t", *it);
if (_msgHandler)
_msgHandler->dumpState(os);
@@ -336,7 +336,7 @@ bool ProxyProtocolHandler::flushQueueTo(const std::shared_ptr<StreamSocket> &soc
return false;
size_t totalSize = 0;
- for (auto it : _writeQueue)
+ for (const auto& it : _writeQueue)
totalSize += it->size();
if (!totalSize)
@@ -354,7 +354,7 @@ bool ProxyProtocolHandler::flushQueueTo(const std::shared_ptr<StreamSocket> &soc
"\r\n";
socket->send(oss.str());
- for (auto it : _writeQueue)
+ for (const auto& it : _writeQueue)
socket->send(it->data(), it->size(), false);
_writeQueue.clear();
More information about the Libreoffice-commits
mailing list