summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-14 20:54:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-15 21:39:24 +0200
commit3c140247d1477d565680731434df7b82d01f4775 (patch)
tree5f4eb02db1454c71362f163f203853ab0ee1b6ef
parenttdf#149049 related: fix media object inserts twice in Writer (diff)
downloadcore-3c140247d1477d565680731434df7b82d01f4775.tar.gz
core-3c140247d1477d565680731434df7b82d01f4775.zip
don't construct SequenceAsHashMap just to extract a couple of properties
because construcing SequenceAsHashMap requires allocating a bunch of heap objects Change-Id: I2bb1d05b23613d8c8f8a475e006b313578c18c5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134343 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--comphelper/source/misc/mimeconfighelper.cxx17
1 files changed, 14 insertions, 3 deletions
diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx
index 8f24aa175592..3b234b6591ae 100644
--- a/comphelper/source/misc/mimeconfighelper.cxx
+++ b/comphelper/source/misc/mimeconfighelper.cxx
@@ -728,8 +728,19 @@ OUString MimeConfigurationHelper::GetDefaultFilterFromServiceName( const OUStrin
uno::Sequence< beans::PropertyValue > aProps;
if ( xFilterEnum->nextElement() >>= aProps )
{
- SequenceAsHashMap aPropsHM( aProps );
- SfxFilterFlags nFlags = static_cast<SfxFilterFlags>(aPropsHM.getUnpackedValueOrDefault( "Flags", sal_Int32(0) ));
+ SfxFilterFlags nFlags = SfxFilterFlags::NONE;
+ OUString sName;
+ for (const auto & rPropVal : aProps)
+ {
+ if (rPropVal.Name == "Flags")
+ {
+ sal_Int32 nTmp(0);
+ if (rPropVal.Value >>= nTmp)
+ nFlags = static_cast<SfxFilterFlags>(nTmp);
+ }
+ else if (rPropVal.Name == "Name")
+ rPropVal.Value >>= sName;
+ }
// that should be import, export, own filter and not a template filter ( TemplatePath flag )
SfxFilterFlags const nRequired = SfxFilterFlags::OWN
@@ -743,7 +754,7 @@ OUString MimeConfigurationHelper::GetDefaultFilterFromServiceName( const OUStrin
// if there are more than one filter the preferred one should be used
// if there is no preferred filter the first one will be used
if ( aResult.isEmpty() || ( nFlags & SfxFilterFlags::PREFERED ) )
- aResult = aPropsHM.getUnpackedValueOrDefault( "Name", OUString() );
+ aResult = sName;
if ( nFlags & SfxFilterFlags::PREFERED )
break; // the preferred filter was found
}