From b210c45d19e8791402d1f3aa9b3bb5bcd6c95f79 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 13 Apr 2022 07:49:32 +0100 Subject: [PATCH] Move extension preparation out of the loop Change-Id: I6e4b5397e3d0ae9b943e261e9fca95735ccc9a73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132866 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sfx2/source/bastyp/fltfnc.cxx | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index d554d8e9652d..942109db2699 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -652,23 +652,22 @@ std::shared_ptr SfxFilterMatcher::GetFilter4Extension( const OU { if ( m_rImpl.pList ) { - for (const std::shared_ptr& pFilter : *m_rImpl.pList) + if (OUString sExt = ToUpper_Impl(rExt); !sExt.isEmpty()) { - SfxFilterFlags nFlags = pFilter->GetFilterFlags(); - if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) ) + if (sExt[0] != '.') + sExt = "." + sExt; + + for (const std::shared_ptr& pFilter : *m_rImpl.pList) { - OUString sWildCard = ToUpper_Impl( pFilter->GetWildcard().getGlob() ); - OUString sExt = ToUpper_Impl( rExt ); + SfxFilterFlags nFlags = pFilter->GetFilterFlags(); + if ((nFlags & nMust) == nMust && !(nFlags & nDont)) + { + OUString sWildCard = ToUpper_Impl(pFilter->GetWildcard().getGlob()); - if (sExt.isEmpty()) - continue; - - if (sExt[0] != '.') - sExt = "." + sExt; - - WildCard aCheck(sWildCard, ';'); - if (aCheck.Matches(sExt)) - return pFilter; + WildCard aCheck(sWildCard, ';'); + if (aCheck.Matches(sExt)) + return pFilter; + } } }