sw/source/core/txtnode/ndtxt.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 746f710d693a10daf48b5cb5a4f6082d2dafa49a
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Oct 31 20:34:17 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Nov 1 07:01:32 2022 +0100

    tdf#126788 elide OUString construction SwTextNode::InsertText
    
    if the node is empty, we can avoid the cost of constructing a new string
    
    Change-Id: I5792fc0a80019008c4e7f458d4472405123cdeb5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142083
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 409b33837f86..4b2f114d94a3 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2363,7 +2363,10 @@ OUString SwTextNode::InsertText( const OUString & rStr, 
const SwContentIndex & r
     {
         return sInserted;
     }
-    m_Text = m_Text.replaceAt(aPos, 0, sInserted);
+    if (aPos == 0 && m_Text.isEmpty())
+        m_Text = sInserted;
+    else
+        m_Text = m_Text.replaceAt(aPos, 0, sInserted);
     assert(GetSpaceLeft()>=0);
     nLen = m_Text.getLength() - aPos - nLen;
     assert(nLen != 0);

Reply via email to