[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - desktop/inc desktop/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 09:34:05 UTC 2019


 desktop/inc/lib/init.hxx    |    8 ++++++++
 desktop/source/lib/init.cxx |   26 +++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)

New commits:
commit e70246542f0c7ce975a4c972be2e5fbd045f10bb
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Feb 14 10:49:57 2019 -0500
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Mar 5 10:33:42 2019 +0100

    LOK: Cache RectangleAndPart payloads
    
    Change-Id: I3a2d98426729ad1b4e43a8f657b512679be82c26
    Reviewed-on: https://gerrit.libreoffice.org/68268
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index b02329e7f955..66696757292a 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -15,6 +15,8 @@
 #include <memory>
 #include <mutex>
 
+#include <boost/variant.hpp>
+
 #include <osl/thread.h>
 #include <rtl/ref.hxx>
 #include <vcl/idle.hxx>
@@ -98,8 +100,14 @@ namespace desktop {
             {
             }
 
+            /// Parse and set the RectangleAndPart object and return it. Clobbers PayloadString.
+            RectangleAndPart& setRectangleAndPart(const std::string& payload);
+            /// Return the parsed RectangleAndPart instance.
+            const RectangleAndPart& getRectangleAndPart() const;
+
             int Type;
             std::string PayloadString;
+            boost::variant<boost::blank, RectangleAndPart> PayloadObject;
         };
 
         typedef std::vector<CallbackData> queue_type;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b502229d466b..b216928c0db3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -455,6 +455,20 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload)
     aRet.m_nPart = nPart;
     return aRet;
 }
+
+RectangleAndPart& CallbackFlushHandler::CallbackData::setRectangleAndPart(const std::string& payload)
+{
+    PayloadString = payload;
+
+    PayloadObject = RectangleAndPart::Create(payload);
+    return boost::get<RectangleAndPart>(PayloadObject);
+}
+
+const RectangleAndPart& CallbackFlushHandler::CallbackData::getRectangleAndPart() const
+{
+    return boost::get<RectangleAndPart>(PayloadObject);
+}
+
 }
 
 namespace {
@@ -843,9 +857,11 @@ void CallbackFlushHandler::callback(const int type, const char* payload, void* d
 
 void CallbackFlushHandler::queue(const int type, const char* data)
 {
-    std::string payload(data ? data : "(nil)");
+    CallbackData aCallbackData(type, (data ? data : "(nil)"));
+    std::string& payload = aCallbackData.PayloadString;
     SAL_INFO("lok", "Queue: " << type << " : " << payload);
 
+
     if (m_bPartTilePainting)
     {
         // We drop notifications when this is set, except for important ones.
@@ -1002,7 +1018,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
 
             case LOK_CALLBACK_INVALIDATE_TILES:
             {
-                RectangleAndPart rcNew = RectangleAndPart::Create(payload);
+                RectangleAndPart& rcNew = aCallbackData.setRectangleAndPart(payload);
                 if (rcNew.isEmpty())
                 {
                     SAL_INFO("lok", "Skipping invalid event [" << type << "]: [" << payload << "].");
@@ -1015,7 +1031,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                         [] (const queue_type::value_type& elem) { return (elem.Type == LOK_CALLBACK_INVALIDATE_TILES); });
                 if (pos != m_queue.rend())
                 {
-                    const RectangleAndPart rcOld = RectangleAndPart::Create(pos->PayloadString);
+                    const RectangleAndPart& rcOld = pos->getRectangleAndPart();
                     if (rcOld.isInfinite() && (rcOld.m_nPart == -1 || rcOld.m_nPart == rcNew.m_nPart))
                     {
                         SAL_INFO("lok", "Skipping queue [" << type << "]: [" << payload << "] since all tiles need to be invalidated.");
@@ -1059,7 +1075,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
                         [&rcNew] (const queue_type::value_type& elem) {
                             if (elem.Type == LOK_CALLBACK_INVALIDATE_TILES)
                             {
-                                const RectangleAndPart rcOld = RectangleAndPart::Create(elem.PayloadString);
+                                const RectangleAndPart& rcOld = elem.getRectangleAndPart();
                                 if (rcNew.m_nPart != -1 && rcOld.m_nPart != -1 && rcOld.m_nPart != rcNew.m_nPart)
                                 {
                                     SAL_INFO("lok", "Nothing to merge between new: " << rcNew.toString() << ", and old: " << rcOld.toString());
@@ -1274,7 +1290,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
         }
     }
 
-    m_queue.emplace_back(type, payload);
+    m_queue.emplace_back(aCallbackData);
     SAL_INFO("lok", "Queued #" << (m_queue.size() - 1) <<
              " [" << type << "]: [" << payload << "] to have " << m_queue.size() << " entries.");
 


More information about the Libreoffice-commits mailing list