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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 10 16:04:34 UTC 2020


 kit/ChildSession.cpp |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 893b7d880d0cd4ff78fbadd71b4f405e0d987de6
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 10 16:10:07 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Mar 10 17:04:16 2020 +0100

    ChildSession::renderShapeSelection: vector -> unique_ptr
    
    Open Writer, insert a multi-MP JPEG, select it.
    
    Before:
    
    ChildSession::renderShapeSelection: finished in 81.33 ms
    
    After:
    
    ChildSession::renderShapeSelection: finished in 74.67 ms (91.81% of baseline)
    
    This is with an --enable-symbols core with a -O2 online, with libstdc++.
    
    The cost on the Android profile with its libc++ looked even more,
    spending time in the std::vector dtor.
    
    Change-Id: I50af2e13fd24569dc32304420b8f3e70d15803eb
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90262
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index bc9573030..682012a50 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -2181,13 +2181,14 @@ bool ChildSession::renderShapeSelection(const char* /*buffer*/, int /*length*/,
     if (pOutput != nullptr && nOutputSize > 0)
     {
         static const std::string header = "shapeselectioncontent:\n";
-        std::vector<char> response(header.size() + nOutputSize);
-        std::memcpy(response.data(), header.data(), header.size());
-        std::memcpy(response.data() + header.size(), pOutput, nOutputSize);
+        size_t responseSize = header.size() + nOutputSize;
+        std::unique_ptr<char[]> response(new char[responseSize]);
+        std::memcpy(response.get(), header.data(), header.size());
+        std::memcpy(response.get() + header.size(), pOutput, nOutputSize);
         free(pOutput);
 
-        LOG_TRC("Sending response (" << response.size() << " bytes) for shapeselectioncontent on view #" << _viewId);
-        sendBinaryFrame(response.data(), response.size());
+        LOG_TRC("Sending response (" << responseSize << " bytes) for shapeselectioncontent on view #" << _viewId);
+        sendBinaryFrame(response.get(), responseSize);
     }
     else
     {


More information about the Libreoffice-commits mailing list