package/source/xstor/xstorage.cxx |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 240a345bc3891887ed551e780ce619d8da303325
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri May 6 10:40:46 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri May 6 14:22:15 2022 +0200

    tdf#121740 reduce cost of OStorage_Impl::GetElementNames
    
    which shows up on the profile
    
    Change-Id: I7e4ef9d71d06562dc1c574fe41d616947e3d67e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133926
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/package/source/xstor/xstorage.cxx 
b/package/source/xstor/xstorage.cxx
index 0403f2b0f464..a5777deb771e 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -1461,17 +1461,24 @@ uno::Sequence< OUString > 
OStorage_Impl::GetElementNames()
 
     ReadContents();
 
-    std::vector< OUString > aElementNames;
-    aElementNames.reserve( m_aChildrenMap.size() );
+    sal_Int32 nCnt = 0;
+    for ( const auto& pair : m_aChildrenMap )
+        for (auto pElement : pair.second)
+        {
+            if ( !pElement->m_bIsRemoved )
+                nCnt++;
+        }
 
+    uno::Sequence<OUString> aElementNames(nCnt);
+    OUString* pArray = aElementNames.getArray();
     for ( const auto& pair : m_aChildrenMap )
         for (auto pElement : pair.second)
         {
             if ( !pElement->m_bIsRemoved )
-                aElementNames.push_back(pair.first);
+                *pArray++ = pair.first;
         }
 
-    return comphelper::containerToSequence(aElementNames);
+    return aElementNames;
 }
 
 void OStorage_Impl::RemoveElement( OUString const & rName, SotElement_Impl* 
pElement )

Reply via email to