From 608f273e9da412e7a2d884f2603756cb4ff4c8af Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 1 Jul 2021 10:10:35 +0200 Subject: can allocate these SfxItemSet on the stack Change-Id: Ib2b89613ad3e8f2bcdd51bee10bab3559a64fce4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118208 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/uibase/uiview/viewsrch.cxx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'sw/source/uibase/uiview/viewsrch.cxx') diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 911d2cedd1eb..a68d90c08207 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -756,18 +756,17 @@ sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions ) ::SfxToSwPageDescAttr( *m_pWrtShell, aSrchSet ); } - std::unique_ptr pReplSet; + std::optional xReplSet; if( bDoReplace && s_xReplaceList && s_xReplaceList->Count() ) { - pReplSet.reset( new SfxItemSet( m_pWrtShell->GetAttrPool(), - aSearchAttrRange ) ); - s_xReplaceList->Get( *pReplSet ); + xReplSet.emplace( m_pWrtShell->GetAttrPool(), aSearchAttrRange ); + s_xReplaceList->Get( *xReplSet ); // -- Page break with page template - ::SfxToSwPageDescAttr( *m_pWrtShell, *pReplSet ); + ::SfxToSwPageDescAttr( *m_pWrtShell, *xReplSet ); - if( !pReplSet->Count() ) // too bad, we don't know - pReplSet.reset(); // the attributes + if( !xReplSet->Count() ) // too bad, we don't know + xReplSet.reset(); // the attributes } // build SearchOptions to be used @@ -778,7 +777,7 @@ sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions ) aSearchOpt.replaceString.clear(); sal_uLong nFound; - if( aSrchSet.Count() || ( pReplSet && pReplSet->Count() )) + if( aSrchSet.Count() || ( xReplSet && xReplSet->Count() )) { nFound = m_pWrtShell->SearchAttr( aSrchSet, @@ -787,7 +786,7 @@ sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions ) rOptions.eEnd, eRanges, !s_pSrchItem->GetSearchString().isEmpty() ? &aSearchOpt : nullptr, - pReplSet.get() ); + xReplSet ? &*xReplSet : nullptr ); } else if( s_pSrchItem->GetPattern() ) { -- cgit