sw/source/filter/ww8/docxattributeoutput.cxx |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 468b17bd06e56b406f5651d7f0e9c7bef54090e0
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Sat Jun 8 20:51:26 2024 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Tue Jun 11 00:50:03 2024 +0200

    NFC docxattributeoutput loop: skip if empty, exit early if duplicate
    
    No need to loop through all of the textboxes
    if the rName.isEmpty() since that is never accepted as a duplicate.
    As soon as a valid duplicate is found,
    we can quit search the rest.
    
    Change-Id: I785c2cf4cc619fc45fc2b95f492fe1b5ff0f1a55
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168582
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 97a4c038c736..1d3c806843af 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6329,15 +6329,19 @@ void DocxAttributeOutput::WriteFlyFrame(const 
ww8::Frame& rFrame)
                 // The frame output is postponed to the end of the anchor 
paragraph
                 bool bDuplicate = false;
                 const OUString& rName = rFrame.GetFrameFormat().GetName();
-                unsigned nSize = m_aFramesOfParagraph.size() ? 
m_aFramesOfParagraph.top().size() : 0;
-                for( unsigned nIndex = 0; nIndex < nSize; ++nIndex )
+                if (m_aFramesOfParagraph.size() && !rName.isEmpty())
                 {
-                    const OUString& rNameExisting = 
m_aFramesOfParagraph.top()[nIndex].GetFrameFormat().GetName();
-
-                    if (!rName.isEmpty() && !rNameExisting.isEmpty())
+                    const unsigned nSize = m_aFramesOfParagraph.top().size();
+                    for (unsigned nIndex = 0; nIndex < nSize; ++nIndex)
                     {
+                        const OUString& rNameExisting
+                            = 
m_aFramesOfParagraph.top()[nIndex].GetFrameFormat().GetName();
+
                         if (rName == rNameExisting)
+                        {
                             bDuplicate = true;
+                            break;
+                        }
                     }
                 }
 

Reply via email to