sw/source/core/crsr/crstrvl.cxx |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 5ae0fcbc4a93cbc52071cf6ecfe271031af3ec27
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Aug 7 13:44:44 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Aug 8 18:59:35 2022 +0200

    no need to allocate on heap in lcl_FindField
    
    Change-Id: Ia9172292220f6935e4a21b659d07dc317c060740
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137939
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index d0f9fdc2b414..3d03a483c646 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -661,16 +661,16 @@ lcl_FindField(bool & o_rFound, SetGetExpFields const& 
rSrtLst,
         SwTextField const *const pTextField, SwPosition const& rPos,
         sal_Int32 const nContentOffset)
 {
-    std::unique_ptr<SetGetExpField> pSrch;
-    std::unique_ptr<SwContentIndex> pIndex;
+    std::optional<SetGetExpField> oSrch;
+    std::optional<SwContentIndex> oIndex;
     if (-1 == nContentOffset)
     {
-        pSrch.reset(new SetGetExpField(rPos.GetNode(), pTextField, 
&rPos.nContent));
+        oSrch.emplace(rPos.GetNode(), pTextField, &rPos.nContent);
     }
     else
     {
-        pIndex.reset(new SwContentIndex(rPos.GetNode().GetContentNode(), 
nContentOffset));
-        pSrch.reset(new SetGetExpField(rPos.GetNode(), pTextField, 
pIndex.get()));
+        oIndex.emplace(rPos.GetNode().GetContentNode(), nContentOffset);
+        oSrch.emplace(rPos.GetNode(), pTextField, &*oIndex);
     }
 
     if (rPos.GetNodeIndex() < 
pTextNode->GetNodes().GetEndOfExtras().GetIndex())
@@ -678,12 +678,12 @@ lcl_FindField(bool & o_rFound, SetGetExpFields const& 
rSrtLst,
         // also at collection use only the first frame
         Point aPt;
         std::pair<Point, bool> const tmp(aPt, false);
-        pSrch->SetBodyPos(*pTextNode->getLayoutFrame(pLayout, &rPos, &tmp));
+        oSrch->SetBodyPos(*pTextNode->getLayoutFrame(pLayout, &rPos, &tmp));
     }
 
-    SetGetExpFields::const_iterator it = rSrtLst.lower_bound(pSrch.get());
+    SetGetExpFields::const_iterator it = rSrtLst.lower_bound(&*oSrch);
 
-    o_rFound = (it != rSrtLst.end()) && (**it == *pSrch);
+    o_rFound = (it != rSrtLst.end()) && (**it == *oSrch);
     return it;
 }
 

Reply via email to