desktop/inc/lib/init.hxx | 3 +++ desktop/source/lib/init.cxx | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)
New commits: commit 166b5d8146159bf54a4e3f67c578e60a9ddac2d1 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Fri Feb 15 09:39:57 2019 -0500 Commit: Ashod Nakashian <ashnak...@gmail.com> CommitDate: Fri Feb 22 15:42:43 2019 +0100 LOK: reuse cached json object for ViewId where available Change-Id: I5e29ec2863e06d3dfcbad95c55e355805f12e259 Reviewed-on: https://gerrit.libreoffice.org/67895 Tested-by: Jenkins Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 2ba5595d8b46..013162aa990f 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -116,6 +116,9 @@ namespace desktop { /// Validate that the payload and parsed object match. bool validate() const; + /// Returns true iff there is cached data. + bool isCached() const { return PayloadObject.which() != 0; } + int Type; std::string PayloadString; diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index bf36321fc9a0..0b405be858e0 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -575,6 +575,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-----"); @@ -1076,7 +1083,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)); } ); } @@ -1373,11 +1380,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) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits