diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-11 11:02:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-11 15:17:15 +0200 |
commit | cd0586f2d52699b1270e307c7cd76470ab40b7c3 (patch) | |
tree | 6728a8baf2c8497e12590d22c10148b898568c4c | |
parent | 9d450875c8a0bea2468f65c7a57b9ff77344b6c8 (diff) |
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.grandin@collabora.co.uk>
-rw-r--r-- | comphelper/source/misc/sequenceashashmap.cxx | 4 |
1 files changed, 4 insertions, 0 deletions
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; |