From c39978f41dccbeb2e973c919a67d9b1d974f8f3c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 27 Jul 2024 15:39:06 +0200 Subject: 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 Tested-by: Jenkins --- include/svl/itemprop.hxx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'include/svl') diff --git a/include/svl/itemprop.hxx b/include/svl/itemprop.hxx index f3db2f2eb6d9..ddd636272ea4 100644 --- a/include/svl/itemprop.hxx +++ b/include/svl/itemprop.hxx @@ -69,29 +69,23 @@ struct SfxItemPropertyMapEntry } }; -struct SfxItemPropertyMapCompare -{ - bool operator() ( const SfxItemPropertyMapEntry * lhs, const SfxItemPropertyMapEntry * rhs ) const - { - return lhs->aName < rhs->aName; - } -}; class SVL_DLLPUBLIC SfxItemPropertyMap { - o3tl::sorted_vector< const SfxItemPropertyMapEntry*, SfxItemPropertyMapCompare > m_aMap; - mutable css::uno::Sequence< css::beans::Property > m_aPropSeq; public: SfxItemPropertyMap( std::span pEntries ); SfxItemPropertyMap( const SfxItemPropertyMap& rSource ); ~SfxItemPropertyMap(); - const SfxItemPropertyMapEntry* getByName( std::u16string_view rName ) const; + const SfxItemPropertyMapEntry* getByName( const OUString & rName ) const; css::uno::Sequence< css::beans::Property > const & getProperties() const; /// @throws css::beans::UnknownPropertyException css::beans::Property getPropertyByName( const OUString & rName ) const; - bool hasPropertyByName( std::u16string_view rName ) const; + bool hasPropertyByName( const OUString & rName ) const; - const o3tl::sorted_vector< const SfxItemPropertyMapEntry*, SfxItemPropertyMapCompare >& getPropertyEntries() const { return m_aMap; } + const std::unordered_map< OUString, const SfxItemPropertyMapEntry* >& getPropertyEntries() const { return m_aMap; } +private: + std::unordered_map< OUString, const SfxItemPropertyMapEntry* > m_aMap; + mutable css::uno::Sequence< css::beans::Property > m_aPropSeq; }; class SVL_DLLPUBLIC SfxItemPropertySet final -- cgit