summaryrefslogtreecommitdiff
path: root/desktop/inc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-08-04 13:01:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-04 22:02:28 +0200
commit3b3e4ee97af23f210fa39f1af3ddf1de63291371 (patch)
treef18b9679b9574a2ec3d415e75000f700231b8924 /desktop/inc
parent73c5ff374629f3e6bb92fcd52ab8597d52c67af9 (diff)
speed up scanning the LOK queue
we frequently scan the queue to caolesce events. Most of the time we are scanning based on the event type. So split the queue data into a compact queue that only contains the type, and another queue for the rest of the data. That makes the scanning __much__ more cache-friendly. Change-Id: I92d0b95611cd139cac8532f9297eaabda71d5fe9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119996 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit acf9cf33d53e4bf598ddbdab102bfbd6bb14f8a3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121558 Tested-by: Jenkins
Diffstat (limited to 'desktop/inc')
-rw-r--r--desktop/inc/lib/init.hxx23
1 files changed, 13 insertions, 10 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index e27f0563cd58..e6b4f00a5427 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -93,9 +93,8 @@ namespace desktop {
struct CallbackData
{
- CallbackData(int type, const std::string& payload)
- : Type(type)
- , PayloadString(payload)
+ CallbackData(const std::string& payload)
+ : PayloadString(payload)
{
}
@@ -118,7 +117,6 @@ namespace desktop {
/// Returns true iff there is cached data.
bool isCached() const { return PayloadObject.which() != 0; }
- int Type;
std::string PayloadString;
private:
@@ -126,14 +124,19 @@ namespace desktop {
boost::variant<boost::blank, RectangleAndPart, boost::property_tree::ptree> PayloadObject;
};
- typedef std::vector<CallbackData> queue_type;
+ typedef std::vector<int> queue_type1;
+ typedef std::vector<CallbackData> queue_type2;
private:
- bool removeAll(const std::function<bool (const queue_type::value_type&)>& rTestFunc);
- bool processInvalidateTilesEvent(CallbackData& aCallbackData);
- bool processWindowEvent(CallbackData& aCallbackData);
-
- queue_type m_queue;
+ bool removeAll(const std::function<bool (int, const CallbackData&)>& rTestFunc);
+ bool processInvalidateTilesEvent(int type, CallbackData& aCallbackData);
+ bool processWindowEvent(int type, CallbackData& aCallbackData);
+ queue_type2::reverse_iterator toQueue2(queue_type1::reverse_iterator);
+
+ /** we frequently want to scan the queue, and mostly when we do so, we only care about the element type
+ so we split the queue in 2 to make the scanning cache friendly. */
+ queue_type1 m_queue1;
+ queue_type2 m_queue2;
std::map<int, std::string> m_states;
std::unordered_map<int, std::unordered_map<int, std::string>> m_viewStates;
LibreOfficeKitDocument* m_pDocument;