From 31e7845339b30a69f06a04619660398fe4267268 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 17 Feb 2022 12:19:49 +0200 Subject: use more SfxItemSet::CloneAsValue to reduce heap allocations Change-Id: Ia755c3e7f9610a5441a447cc74ea38ebcef068bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130066 Tested-by: Jenkins Reviewed-by: Noel Grandin --- editeng/source/uno/unotext.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'editeng/source/uno') diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 81549327bf24..60e19748fcd8 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -601,16 +601,16 @@ uno::Any SvxUnoTextRangeBase::_getPropertyValue(const OUString& PropertyName, sa const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName ); if( pMap ) { - std::unique_ptr pAttribs; + std::optional oAttribs; if( nPara != -1 ) - pAttribs = pForwarder->GetParaAttribs( nPara ).Clone(); + oAttribs.emplace(pForwarder->GetParaAttribs( nPara ).CloneAsValue()); else - pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone(); + oAttribs.emplace(pForwarder->GetAttribs( GetSelection() ).CloneAsValue()); // Replace Dontcare with Default, so that one always has a mirror - pAttribs->ClearInvalidItems(); + oAttribs->ClearInvalidItems(); - getPropertyValue( pMap, aAny, *pAttribs ); + getPropertyValue( pMap, aAny, *oAttribs ); return aAny; } @@ -879,13 +879,13 @@ uno::Sequence< uno::Any > SvxUnoTextRangeBase::_getPropertyValues( const uno::Se SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; if( pForwarder ) { - std::unique_ptr pAttribs; + std::optional oAttribs; if( nPara != -1 ) - pAttribs = pForwarder->GetParaAttribs( nPara ).Clone(); + oAttribs.emplace(pForwarder->GetParaAttribs( nPara ).CloneAsValue()); else - pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone(); + oAttribs.emplace(pForwarder->GetAttribs( GetSelection() ).CloneAsValue() ); - pAttribs->ClearInvalidItems(); + oAttribs->ClearInvalidItems(); const OUString* pPropertyNames = aPropertyNames.getConstArray(); uno::Any* pValues = aValues.getArray(); @@ -895,7 +895,7 @@ uno::Sequence< uno::Any > SvxUnoTextRangeBase::_getPropertyValues( const uno::Se const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames ); if( pMap ) { - getPropertyValue( pMap, *pValues, *pAttribs ); + getPropertyValue( pMap, *pValues, *oAttribs ); } } } -- cgit