include/svx/svdpage.hxx       |    7 ++++++-
 svx/source/svdraw/svdogrp.cxx |    8 ++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 0280a9ef0d93bb2c8ec713b6dc36b77962b57e99
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Oct 18 09:45:56 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Oct 18 12:11:14 2023 +0200

    tdf#155410 shave 1% cost off SdrGroup::GetLayer
    
    by avoiding repeated indexed lookup into the std::deque inside
    SdrObjList
    
    Change-Id: Ifcf736d0ecef1239b8a236fe1937f347a3d49e4e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158104
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 97142d661296..7ab37532c046 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -225,10 +225,15 @@ public:
 
     virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
+    typedef std::deque<rtl::Reference<SdrObject>> SdrObjectDeque;
+
+    SdrObjectDeque::const_iterator begin() const { return maList.begin(); }
+    SdrObjectDeque::const_iterator end() const { return maList.end(); }
+
 private:
     tools::Rectangle    maSdrObjListOutRect;
     tools::Rectangle    maSdrObjListSnapRect;
-    std::deque<rtl::Reference<SdrObject>> maList;
+    SdrObjectDeque maList;
     /// This list, if it exists, defines the navigation order. If it does
     /// not exist then maList defines the navigation order.
     std::optional<std::vector<unotools::WeakReference<SdrObject>>> 
mxNavigationOrder;
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index 6c63e258a963..8a518554827a 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -174,11 +174,11 @@ SdrObjKind SdrObjGroup::GetObjIdentifier() const
 
 SdrLayerID SdrObjGroup::GetLayer() const
 {
-    bool b1st = true;
     SdrLayerID nLay = SdrObject::GetLayer();
-    const size_t nObjCount(GetObjCount());
-    for (size_t i=0; i<nObjCount; ++i) {
-        SdrLayerID nLay1(GetObj(i)->GetLayer());
+    bool b1st = true;
+    for (const rtl::Reference<SdrObject>& pObject : *this)
+    {
+        SdrLayerID nLay1(pObject->GetLayer());
         if (b1st) { nLay=nLay1; b1st = false; }
         else if (nLay1!=nLay) return SdrLayerID(0);
     }

Reply via email to