comphelper/source/misc/sequenceashashmap.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit cd0586f2d52699b1270e307c7cd76470ab40b7c3
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 11 11:02:34 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed May 11 15:17:15 2022 +0200

    reserve space for bulk operations in SequenceAsHashMap
    
    reduces the number of allocations we do
    
    Change-Id: If8e61c8b0dd1942278d7adc1fa87580734aeeb99
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134157
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/comphelper/source/misc/sequenceashashmap.cxx 
b/comphelper/source/misc/sequenceashashmap.cxx
index 0f15823651f9..b9662fbddbab 100644
--- a/comphelper/source/misc/sequenceashashmap.cxx
+++ b/comphelper/source/misc/sequenceashashmap.cxx
@@ -158,6 +158,7 @@ void SequenceAsHashMap::operator<<(const 
css::uno::Sequence< css::uno::Any >& lS
     sal_Int32 c = lSource.getLength();
     sal_Int32 i = 0;
 
+    m_aMap.reserve(c);
     for (i=0; i<c; ++i)
     {
         css::beans::PropertyValue lP;
@@ -203,6 +204,7 @@ void SequenceAsHashMap::operator<<(const 
css::uno::Sequence< css::beans::Propert
     sal_Int32                        c       = lSource.getLength();
     const css::beans::PropertyValue* pSource = lSource.getConstArray();
 
+    m_aMap.reserve(c);
     for (sal_Int32 i=0; i<c; ++i)
         (*this)[pSource[i].Name] = pSource[i].Value;
 }
@@ -214,6 +216,7 @@ void SequenceAsHashMap::operator<<(const 
css::uno::Sequence< css::beans::NamedVa
     sal_Int32                     c       = lSource.getLength();
     const css::beans::NamedValue* pSource = lSource.getConstArray();
 
+    m_aMap.reserve(c);
     for (sal_Int32 i=0; i<c; ++i)
         (*this)[pSource[i].Name] = pSource[i].Value;
 }
@@ -297,6 +300,7 @@ bool SequenceAsHashMap::match(const SequenceAsHashMap& 
rCheck) const
 
 void SequenceAsHashMap::update(const SequenceAsHashMap& rUpdate)
 {
+    m_aMap.reserve(std::max(size(), rUpdate.size()));
     for (auto const& elem : rUpdate)
     {
         const OUString& sName  = elem.first;

Reply via email to