sfx2/source/bastyp/fltfnc.cxx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
New commits: commit 498f464ea7d60698192ec609fa4ee856123814a4 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sat May 21 08:31:24 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat May 21 09:49:27 2022 +0200 cheaper to loop over Sequence than construct SequenceAsHashMap Change-Id: Idbf9a104677bd0934e56803d96e233f52fc763e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134700 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index e1dadb2a1fb9..56638fc1c9d2 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -569,16 +569,24 @@ std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilterForProps( const css: // make query for all types matching the properties uno::Reference < css::container::XEnumeration > xEnum = xTypeCFG->createSubSetEnumerationByProperties( aSeq ); - ::comphelper::SequenceAsHashMap aProps; + uno::Sequence<beans::PropertyValue> aProps; while ( xEnum->hasMoreElements() ) { - aProps << xEnum->nextElement(); - - OUString aValue; static constexpr OUStringLiteral sPreferredFilter = u"PreferredFilter"; + static constexpr OUStringLiteral sName = u"Name"; + + xEnum->nextElement() >>= aProps; + OUString aValue, aName; + for( const auto & rPropVal : aProps) + { + if (rPropVal.Name == sPreferredFilter) + rPropVal.Value >>= aValue; + else if (rPropVal.Name == sName) + rPropVal.Value >>= aName; + } + // try to get the preferred filter (works without loading all filters!) - auto it = aProps.find(sPreferredFilter); - if ( it != aProps.end() && (it->second >>= aValue) && !aValue.isEmpty() ) + if ( !aValue.isEmpty() ) { std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetFilterByName( aValue ); if ( !pFilter || (pFilter->GetFilterFlags() & nMust) != nMust || (pFilter->GetFilterFlags() & nDont ) ) @@ -593,13 +601,7 @@ std::shared_ptr<const SfxFilter> SfxFilterMatcher::GetFilterForProps( const css: { // preferred filter belongs to another document type; now we must search the filter m_rImpl.InitForIterating(); - static constexpr OUStringLiteral sName = u"Name"; - it = aProps.find(sName); - if (it != aProps.end()) - it->second >>= aValue; - else - aValue.clear(); - pFilter = GetFilter4EA( aValue, nMust, nDont ); + pFilter = GetFilter4EA( aName, nMust, nDont ); if ( pFilter ) return pFilter; }