sw/source/core/table/swtable.cxx |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

New commits:
commit bdf3114180a1d35d5018b5b6bf73db983df68162
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Mar 5 08:45:56 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Mar 5 14:52:10 2026 +0100

    sw: Avoid intermediate string allocation
    
    As Mike Kaganski points out in [1]:
    
    > OUString::number returns an on-stack object; but then the result is
    > converted to OUString - that is allocated from heap.
    > [...]; in case of concatenations, using the original
    > object returned from OUString::number would be better, not requiring
    > intermediate allocations.
    
    [1] 
https://gerrit.libreoffice.org/c/core/+/200942/comment/d4f6bdf4_1772d643/
    
    Change-Id: I1e8c0062be079ff1475fa60e5edd4c9a094f85b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201002
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 58ecc0896bdb..a24cfe8ef32a 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2251,23 +2251,17 @@ OUString SwTableBox::GetName() const
                 ? &pLine->GetUpper()->GetTabLines() : &rTable.GetTabLines();
 
         sal_uInt16 nPos = pLines->GetPos(pLine) + 1;
-        OUString sTmp = OUString::number(nPos);
         if( !sNm.isEmpty() )
-            sNm = sTmp + "." + sNm;
+            sNm = OUString::number(nPos) + "." + sNm;
         else
-            sNm = sTmp;
+            sNm = OUString::number(nPos);
 
         nPos = pBox->GetUpper()->GetBoxPos( pBox );
         pBox = pLine->GetUpper();
         if (pBox)
-        {
-            sTmp = OUString::number(nPos + 1);
-            sNm = sTmp + "." + sNm;
-        }
+            sNm = OUString::number(nPos + 1) + "." + sNm;
         else
-        {
             sNm = sw_GetTableBoxColStr(nPos) + sNm;
-        }
 
     } while( pBox );
     return sNm;

Reply via email to