sw/source/core/txtnode/ndtxt.cxx | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
New commits: commit 47e82cfa883b41e6a43285d78b16d20238f166cf Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Aug 30 10:46:06 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 30 14:35:40 2024 +0200 no need to heap allocate the collector in its empty state it is only three words big Change-Id: I5e3984126bcc5efe8fd2cc6c717d31fb2272408f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172644 Tested-by: Jenkins 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 f5686e486e54..972cccd9b512 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1266,7 +1266,7 @@ void SwTextNode::Update( assert(rPos.GetContentNode() == this); SetAutoCompleteWordDirty( true ); - std::unique_ptr<SwpHts> pCollector; + SwpHts aCollector; const sal_Int32 nChangePos = rPos.GetIndex(); if ( HasHints() ) @@ -1389,22 +1389,18 @@ void SwTextNode::Update( } else if( bNoExp ) { - if (!pCollector) - { - pCollector.reset( new SwpHts ); - } - auto it = std::find_if(pCollector->begin(), pCollector->end(), + auto it = std::find_if(aCollector.begin(), aCollector.end(), [nWhich](const SwTextAttr *pTmp) { return nWhich == pTmp->Which(); }); - if (it != pCollector->end()) + if (it != aCollector.end()) { SwTextAttr *pTmp = *it; - pCollector->erase( it ); + aCollector.erase( it ); SwTextAttr::Destroy( pTmp ); } SwTextAttr * const pTmp = MakeTextAttr( GetDoc(), pHint->GetAttr(), nChangePos, nChangePos + nChangeLen); - pCollector->push_back( pTmp ); + aCollector.push_back( pTmp ); } else { @@ -1594,13 +1590,9 @@ void SwTextNode::Update( // base class SwContentIndexReg::Update(rPos, nChangeLen, eMode); - if (pCollector) + for ( SwTextAttr* pAttr : aCollector ) { - const size_t nCount = pCollector->size(); - for ( size_t i = 0; i < nCount; ++i ) - { - m_pSwpHints->TryInsertHint( (*pCollector)[ i ], *this ); - } + m_pSwpHints->TryInsertHint( pAttr, *this ); } aTmpIdxReg.MoveTo( *this );