diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-14 20:54:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-15 21:39:24 +0200 |
commit | 3c140247d1477d565680731434df7b82d01f4775 (patch) | |
tree | 5f4eb02db1454c71362f163f203853ab0ee1b6ef /comphelper/source/misc/mimeconfighelper.cxx | |
parent | 2daceaba6f2d1666e195af9a8e5dc8c4a703c293 (diff) |
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>
Diffstat (limited to 'comphelper/source/misc/mimeconfighelper.cxx')
-rw-r--r-- | comphelper/source/misc/mimeconfighelper.cxx | 17 |
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 } |