diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2019-02-15 09:39:57 -0500 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2019-03-05 23:01:22 +0100 |
commit | 338708e46cf947e6381cd3e5a5be1993c483b045 (patch) | |
tree | 351136bf49d512a03e14b1ad00665a00ec080513 /desktop/source/lib | |
parent | cffa813b8213122dba1206c362ec77a2343f48ba (diff) |
LOK: reuse cached json object for ViewId where available
Change-Id: I5e29ec2863e06d3dfcbad95c55e355805f12e259
Reviewed-on: https://gerrit.libreoffice.org/68272
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'desktop/source/lib')
-rw-r--r-- | desktop/source/lib/init.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b621f134b5f4..262b722ece7f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -94,7 +94,6 @@ #include <sfx2/msgpool.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/lokcharthelper.hxx> -#include <sfx2/lokhelper.hxx> #include <sfx2/DocumentSigner.hxx> #include <svx/dialmgr.hxx> #include <svx/dialogs.hrc> @@ -578,6 +577,13 @@ int lcl_getViewId(const std::string& payload) return 0; } +int lcl_getViewId(const desktop::CallbackFlushHandler::CallbackData& rCallbackData) +{ + if (rCallbackData.isCached()) + return rCallbackData.getJson().get<int>("viewId"); + return lcl_getViewId(rCallbackData.PayloadString); +} + std::string extractCertificate(const std::string & certificate) { const std::string header("-----BEGIN CERTIFICATE-----"); @@ -1079,7 +1085,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) const int nViewId = lcl_getViewId(payload); removeAll( [type, nViewId] (const queue_type::value_type& elem) { - return (elem.Type == type && nViewId == lcl_getViewId(elem.PayloadString)); + return (elem.Type == type && nViewId == lcl_getViewId(elem)); } ); } @@ -1380,11 +1386,11 @@ void CallbackFlushHandler::Invoke() std::unique_lock<std::mutex> lock(m_mutex); SAL_INFO("lok", "Flushing " << m_queue.size() << " elements."); - for (auto& pair : m_queue) + for (const auto& rCallbackData : m_queue) { - const int type = pair.Type; - const auto& payload = pair.PayloadString; - const int viewId = lcl_isViewCallbackType(type) ? lcl_getViewId(payload) : -1; + const int type = rCallbackData.Type; + const auto& payload = rCallbackData.PayloadString; + const int viewId = lcl_isViewCallbackType(type) ? lcl_getViewId(rCallbackData) : -1; if (viewId == -1) { |