[Libreoffice-commits] online.git: kit/Kit.cpp

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 11 08:08:43 UTC 2020


 kit/Kit.cpp |   23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

New commits:
commit 7ecae1b66de938a3186f05698e3c5aac3bc03eab
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 10 17:21:04 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Mar 11 09:08:25 2020 +0100

    Document::sendFrame: vector -> unique_ptr
    
    Open Writer, insert a multi-MP JPEG, select it.
    
    Before:
    
    ChildSession::renderShapeSelection: finished in 74.67 ms
    
    After:
    
    ChildSession::renderShapeSelection: finished in 67.33 ms (90.17% of baseline)
    
    Change-Id: I495e9fcf0c42b0bcfc7987a402a13f5d8664b1e1
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90291
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 0b417f5e4..a302f6e35 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -752,16 +752,16 @@ public:
     const std::string& getUrl() const { return _url; }
 
     /// Post the message - in the unipoll world we're in the right thread anyway
-    bool postMessage(const std::shared_ptr<std::vector<char>>& message, const WSOpCode code) const
+    bool postMessage(const char* data, int size, const WSOpCode code) const
     {
-        LOG_TRC("postMessage called with: " << getAbbreviatedMessage(message->data(), message->size()));
+        LOG_TRC("postMessage called with: " << getAbbreviatedMessage(data, size));
         if (!_websocketHandler)
         {
-            LOG_ERR("Child Doc: Bad socket while sending [" << getAbbreviatedMessage(message->data(), message->size()) << "].");
+            LOG_ERR("Child Doc: Bad socket while sending [" << getAbbreviatedMessage(data, size) << "].");
             return false;
         }
 
-        _websocketHandler->sendMessage(message->data(), message->size(), code);
+        _websocketHandler->sendMessage(data, size, code);
         return true;
     }
 
@@ -1150,11 +1150,12 @@ public:
 
         LOG_TRC("Sending back painted tiles for " << tileMsg << " of size " << output.size() << " bytes) for: " << tileMsg);
 
-        std::shared_ptr<std::vector<char>> response = std::make_shared<std::vector<char>>(tileMsg.size() + output.size());
-        std::copy(tileMsg.begin(), tileMsg.end(), response->begin());
-        std::copy(output.begin(), output.end(), response->begin() + tileMsg.size());
+        size_t responseSize = tileMsg.size() + output.size();
+        std::unique_ptr<char[]> response(new char[responseSize]);
+        std::copy(tileMsg.begin(), tileMsg.end(), response.get());
+        std::copy(output.begin(), output.end(), response.get() + tileMsg.size());
 
-        postMessage(response, WSOpCode::Binary);
+        postMessage(response.get(), responseSize, WSOpCode::Binary);
     }
 
     bool sendTextFrame(const std::string& message)
@@ -1166,11 +1167,7 @@ public:
     {
         try
         {
-            std::shared_ptr<std::vector<char>> message = std::make_shared<std::vector<char>>();
-            message->resize(length);
-            std::memcpy(message->data(), buffer, length);
-
-            return postMessage(message, opCode);
+            return postMessage(buffer, length, opCode);
         }
         catch (const Exception& exc)
         {


More information about the Libreoffice-commits mailing list