[Libreoffice-commits] core.git: desktop/inc desktop/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 22 14:35:25 UTC 2019


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

New commits:
commit 17a477c35cc43f37946dcea2b7c27f0f6571e118
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Feb 14 10:49:57 2019 -0500
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Fri Feb 22 15:34:45 2019 +0100

    LOK: Cache RectangleAndPart payloads
    
    Change-Id: I3a2d98426729ad1b4e43a8f657b512679be82c26
    Reviewed-on: https://gerrit.libreoffice.org/67891
    Tested-by: Jenkins
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.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 ea830cf67fbd..d2e732e53497 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -452,6 +452,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 {
@@ -840,9 +854,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.
@@ -999,7 +1015,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 << "].");
@@ -1012,7 +1028,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.");
@@ -1056,7 +1072,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());
@@ -1267,7 +1283,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