diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-06 10:40:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-06 14:22:15 +0200 |
commit | 240a345bc3891887ed551e780ce619d8da303325 (patch) | |
tree | bfe392414238f0e8c92a8f57201a38a48f357b06 /package | |
parent | a88419f54b8aa9c23cd80e04bc47f1b5ef3931ca (diff) |
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.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/xstor/xstorage.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
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 ) |