sfx2/source/bastyp/fltfnc.cxx |   27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

New commits:
commit b210c45d19e8791402d1f3aa9b3bb5bcd6c95f79
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Apr 13 07:49:32 2022 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Apr 13 10:34:07 2022 +0200

    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 <mike.kagan...@collabora.com>

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<const SfxFilter> 
SfxFilterMatcher::GetFilter4Extension( const OU
 {
     if ( m_rImpl.pList )
     {
-        for (const std::shared_ptr<const SfxFilter>& pFilter : *m_rImpl.pList)
+        if (OUString sExt = ToUpper_Impl(rExt); !sExt.isEmpty())
         {
-            SfxFilterFlags nFlags = pFilter->GetFilterFlags();
-            if ( (nFlags & nMust) == nMust && !(nFlags & nDont ) )
-            {
-                OUString sWildCard = ToUpper_Impl( 
pFilter->GetWildcard().getGlob() );
-                OUString sExt      = ToUpper_Impl( rExt );
-
-                if (sExt.isEmpty())
-                    continue;
+            if (sExt[0] != '.')
+                sExt = "." + sExt;
 
-                if (sExt[0] != '.')
-                    sExt = "." + sExt;
+            for (const std::shared_ptr<const SfxFilter>& pFilter : 
*m_rImpl.pList)
+            {
+                SfxFilterFlags nFlags = pFilter->GetFilterFlags();
+                if ((nFlags & nMust) == nMust && !(nFlags & nDont))
+                {
+                    OUString sWildCard = 
ToUpper_Impl(pFilter->GetWildcard().getGlob());
 
-                WildCard aCheck(sWildCard, ';');
-                if (aCheck.Matches(sExt))
-                    return pFilter;
+                    WildCard aCheck(sWildCard, ';');
+                    if (aCheck.Matches(sExt))
+                        return pFilter;
+                }
             }
         }
 

Reply via email to