[Libreoffice-commits] online.git: 2 commits - common/Message.hpp common/StringVector.hpp common/Util.cpp common/Util.hpp test/helpers.hpp wsd/LOOLWSD.hpp wsd/RequestDetails.cpp wsd/ServerURL.hpp

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 2 18:01:34 UTC 2020


 common/Message.hpp      |    2 +-
 common/StringVector.hpp |    7 ++++---
 common/Util.cpp         |    2 +-
 common/Util.hpp         |    6 +++---
 test/helpers.hpp        |    2 +-
 wsd/LOOLWSD.hpp         |    3 ++-
 wsd/RequestDetails.cpp  |    2 +-
 wsd/ServerURL.hpp       |    2 +-
 8 files changed, 14 insertions(+), 12 deletions(-)

New commits:
commit 223a1d08f04f964d2b7a1e7fc9b9467fb5633292
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jun 1 23:21:22 2020 -0400
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Jun 2 20:01:29 2020 +0200

    wsd: performance-unnecessary-value-param
    
    Change-Id: I1eb092c676da8600e0f8ed70cbc7e1f37fdd5a02
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95338
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/common/Message.hpp b/common/Message.hpp
index 320760c5b..cb27e2c97 100644
--- a/common/Message.hpp
+++ b/common/Message.hpp
@@ -118,7 +118,7 @@ public:
     bool isBinary() const { return _type == Type::Binary; }
 
     /// Allows some in-line re-writing of the message
-    void rewriteDataBody(std::function<bool (std::vector<char> &)> func)
+    void rewriteDataBody(const std::function<bool (std::vector<char> &)>& func)
     {
         if (func(_data))
         {
diff --git a/common/Util.cpp b/common/Util.cpp
index b51295ebd..347fc4562 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -841,7 +841,7 @@ namespace Util
         return std::string::npos;
     }
 
-    std::chrono::system_clock::time_point getFileTimestamp(std::string str_path)
+    std::chrono::system_clock::time_point getFileTimestamp(const std::string& str_path)
     {
         struct stat file;
         stat(str_path.c_str(), &file);
diff --git a/common/Util.hpp b/common/Util.hpp
index b4c5c1234..d41f81319 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -1015,7 +1015,7 @@ int main(int argc, char**argv)
     std::string getHttpTime(std::chrono::system_clock::time_point time);
 
     //// Return timestamp of file
-    std::chrono::system_clock::time_point getFileTimestamp(std::string str_path);
+    std::chrono::system_clock::time_point getFileTimestamp(const std::string& str_path);
 
     //// Return time in ISO8061 fraction format
     std::string getIso8601FracformatTime(std::chrono::system_clock::time_point time);
@@ -1059,7 +1059,7 @@ int main(int argc, char**argv)
      * Splits string into vector<string>. Does not accept referenced variables for easy
      * usage like (splitString("test", ..)) or (splitString(getStringOnTheFly(), ..))
      */
-    inline std::vector<std::string> splitStringToVector(std::string const str, const char delim)
+    inline std::vector<std::string> splitStringToVector(const std::string& str, const char delim)
     {
         size_t start;
         size_t end = 0;
@@ -1069,7 +1069,7 @@ int main(int argc, char**argv)
         while ((start = str.find_first_not_of(delim, end)) != std::string::npos)
         {
             end = str.find(delim, start);
-            result.push_back(str.substr(start, end - start));
+            result.emplace_back(str.substr(start, end - start));
         }
         return result;
     }
diff --git a/test/helpers.hpp b/test/helpers.hpp
index e246e5a57..79948f836 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -779,7 +779,7 @@ inline void deleteAll(const std::shared_ptr<LOOLWebSocket>& socket, const std::s
 
 inline std::string getAllText(const std::shared_ptr<LOOLWebSocket>& socket,
                               const std::string& testname,
-                              const std::string expected = std::string(),
+                              const std::string& expected = std::string(),
                               int retry = COMMAND_RETRY_COUNT)
 {
     static const std::string prefix = "textselectioncontent: ";
diff --git a/wsd/ServerURL.hpp b/wsd/ServerURL.hpp
index 4b42f3917..25d968520 100644
--- a/wsd/ServerURL.hpp
+++ b/wsd/ServerURL.hpp
@@ -46,7 +46,7 @@ public:
         _schemeAuthority = serverName;
 
         // A well formed ProxyPrefix will override it.
-        std::string url = proxyPrefix;
+        const std::string& url = proxyPrefix;
         if (url.size() <= 0)
             return;
 
commit fae093d89db086b26af0ae5eebc1a0bef6b9fa68
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Jun 1 22:46:49 2020 -0400
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Jun 2 20:01:16 2020 +0200

    wsd: std::move rather than copy
    
    Change-Id: I7c4eea8aa5ab57444aa395f727e4ce6ac713b665
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95337
    Tested-by: Jenkins
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/common/StringVector.hpp b/common/StringVector.hpp
index 568ebf989..f995c0b0f 100644
--- a/common/StringVector.hpp
+++ b/common/StringVector.hpp
@@ -10,6 +10,7 @@
 #pragma once
 
 #include <string>
+#include <utility>
 #include <vector>
 
 /**
@@ -42,9 +43,9 @@ class StringVector
 public:
     explicit StringVector() = default;
 
-    explicit StringVector(const std::string& string, const std::vector<StringToken>& tokens)
-        : _string(string)
-        , _tokens(tokens)
+    explicit StringVector(std::string string, std::vector<StringToken> tokens)
+        : _string(std::move(string))
+        , _tokens(std::move(tokens))
     {
     }
 
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 1be418618..8d9653cd5 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -15,6 +15,7 @@
 #include <map>
 #include <set>
 #include <string>
+#include <utility>
 
 #include <signal.h>
 
@@ -50,7 +51,7 @@ public:
 
         _name(name),
         _pid(pid),
-        _ws(handler),
+        _ws(std::move(handler)),
         _socket(socket)
     {
         LOG_INF(_name << " ctor [" << _pid << "].");
diff --git a/wsd/RequestDetails.cpp b/wsd/RequestDetails.cpp
index 046eabe7f..b97f0fdff 100644
--- a/wsd/RequestDetails.cpp
+++ b/wsd/RequestDetails.cpp
@@ -70,7 +70,7 @@ RequestDetails::RequestDetails(Poco::Net::HTTPRequest &request, const std::strin
         }
         if (i - start > 1) // ignore empty
             tokens.emplace_back(start, i - start);
-        _pathSegs = StringVector(_uriString, tokens);
+        _pathSegs = StringVector(_uriString, std::move(tokens));
     }
 }
 


More information about the Libreoffice-commits mailing list