Blob Blame History Raw
From c9ee58e5f4e759734377d9e925e4f570d98561a2 Mon Sep 17 00:00:00 2001
From: Michael Stahl <mstahl@redhat.com>
Date: Thu, 12 May 2016 18:55:13 +0200
Subject: [PATCH 1/3] tdf#99722 sw: silly performance issue when firing a11y
 events
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

SwAccessibleEventList_Impl::MoveInvalidXAccToEnd() pointlessly copies every
single element when iterating over the list and then deletes the copy again
(which is expensive due to the WeakReference member).

This speeds up loading the first 500 pages of the bugdoc from 4:20 to
1:37 in a Linux dbgutil build.

(regression from 76c549eb01dcb7b5bf28a271ce00e386f3d388ba)

(cherry picked from commit e3b990a47fc4b0b1191eb15a53badfc71aebc1fc)
Reviewed-on: https://gerrit.libreoffice.org/24978
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 812233147c8b09b59eeb212663727a9063c7c9c6)

Change-Id: I7c7299e5e82095f5a51f395bc5076ca899b59f81
---
 sw/source/core/access/accmap.cxx | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 7e47ad3..e21879d 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -530,17 +530,12 @@ void SwAccessibleEventList_Impl::MoveInvalidXAccToEnd()
         return;
     }
     SwAccessibleEventList_Impl lstEvent;
-    iterator li = begin();
-    for ( ;li != end();)
+    for (iterator li = begin(); li != end(); )
     {
-        SwAccessibleEvent_Impl e = *li;
-        if (e.IsNoXaccParentFrm())
+        if (li->IsNoXaccParentFrm())
         {
-            iterator liNext = li;
-            ++liNext;
-            erase(li);
-            li = liNext;
-            lstEvent.insert(lstEvent.end(),e);
+            lstEvent.insert(lstEvent.end(), *li);
+            li = erase(li);
         }
         else
             ++li;
-- 
2.5.5