Kaydet (Commit) 166b5d81 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

LOK: reuse cached json object for ViewId where available

Change-Id: I5e29ec2863e06d3dfcbad95c55e355805f12e259
Reviewed-on: https://gerrit.libreoffice.org/67895
Tested-by: Jenkins
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 5f978a3b
......@@ -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;
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment