diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-27 15:39:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-29 15:10:19 +0200 |
commit | c39978f41dccbeb2e973c919a67d9b1d974f8f3c (patch) | |
tree | 1a688fd28ac0f97d3afd742de382bf79937790b4 /sw/source | |
parent | 8f008bf4b968f219d2fe97ef8175ef6be0555943 (diff) |
tdf#161846 use unordered_map in SfxItemPropertyMap
with large property maps, even a binary search starts
showing up, but we can do a O(1) search here by using a map
Change-Id: Ie7916076073e6dd393f0a1fb5a0db1b973999408
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171173
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/access/accpara.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/unocore/unocrsrhelper.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 5 |
5 files changed, 13 insertions, 9 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index d1b9e4932f3a..3c828b8e7d99 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1499,8 +1499,9 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl( { const SfxItemPropertyMap& rPropMap = aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_CURSOR )->getPropertyMap(); - for ( const auto pEntry : rPropMap.getPropertyEntries() ) + for ( const auto & rPair : rPropMap.getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; const SfxPoolItem* pItem = pSet->GetItem( pEntry->nWID ); if ( pItem ) { @@ -1688,8 +1689,9 @@ void SwAccessibleParagraph::_getRunAttributesImpl( const SfxItemPropertyMap& rPropMap = aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_CURSOR )->getPropertyMap(); - for ( const auto pEntry : rPropMap.getPropertyEntries() ) + for ( const auto & rPair : rPropMap.getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; const SfxPoolItem* pItem( nullptr ); // #i82637# - Found character attributes, whose value equals the value of // the corresponding default character attributes, are excluded. diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 88c2baafd61d..cf2e54d42e5d 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -303,8 +303,9 @@ static uno::Any GetParaListAutoFormat(SwTextNode const& rNode) SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap()); std::vector<beans::NamedValue> props; // have to iterate the map, not the item set? - for (auto const pEntry : rMap.getPropertyEntries()) + for (auto const & rPair : rMap.getPropertyEntries()) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; if (SfxItemPropertySet::getPropertyState(*pEntry, *pSet) == PropertyState_DIRECT_VALUE) { Any value; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 253765e889a5..530eb215cf22 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -307,7 +307,7 @@ static sal_Int32 lcl_PropName2TokenPos(std::u16string_view rPropertyName) return SAL_MAX_INT32; } -static sal_uInt16 GetFieldTypeMId( std::u16string_view rProperty, const SwFieldType& rTyp ) +static sal_uInt16 GetFieldTypeMId( const OUString& rProperty, const SwFieldType& rTyp ) { sal_uInt16 nId = lcl_GetPropMapIdForFieldType( rTyp.Which() ); const SfxItemPropertySet* pSet = aSwMapProvider.GetPropertySet( nId ); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index ad86db593144..84bc53608a26 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1861,7 +1861,7 @@ SwXTextCursor::setString(const OUString& aString) uno::Any SwUnoCursorHelper::GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, - std::u16string_view rPropertyName) + const OUString& rPropertyName) { uno::Any aAny; SfxItemPropertyMapEntry const*const pEntry = @@ -2153,7 +2153,7 @@ lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc, void SwUnoCursorHelper::SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, - std::u16string_view rPropertyName) + const OUString& rPropertyName) { SwDoc& rDoc = rPaM.GetDoc(); SfxItemPropertyMapEntry const*const pEntry = @@ -2191,7 +2191,7 @@ void SwUnoCursorHelper::SetPropertyToDefault( uno::Any SwUnoCursorHelper::GetPropertyDefault( SwPaM const & rPaM, const SfxItemPropertySet& rPropSet, - std::u16string_view rPropertyName) + const OUString& rPropertyName) { SfxItemPropertyMapEntry const*const pEntry = rPropSet.getPropertyMap().getByName(rPropertyName); diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a6efe66e988a..ebabef689cef 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -521,7 +521,7 @@ public: : mrMap(rMap) { } - bool AllowsKey(std::u16string_view rName) + bool AllowsKey(const OUString& rName) { return mrMap.hasPropertyByName(rName); } @@ -4186,8 +4186,9 @@ uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() // TODO: Optimize - and fix! the old iteration filled each WhichId // only once but there are more properties than WhichIds - for( const auto pEntry : rMap.getPropertyEntries() ) + for( const auto & rPair : rMap.getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; if ( pEntry->nWID == nWID ) { beans::PropertyValue aPropertyValue; |