diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-21 08:31:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-21 09:49:27 +0200 |
commit | 498f464ea7d60698192ec609fa4ee856123814a4 (patch) | |
tree | c2067891f7376432426d735208458ee399cf8123 /sfx2 | |
parent | 6e24713c8cb4d2c1aec8ee647c07c6b03de0063a (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/bastyp/fltfnc.cxx | 28 |
1 files changed, 15 insertions, 13 deletions
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; } |