From 2484de6728bd11bb7949003d112f1ece2223c7a1 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 14 Oct 2021 09:25:24 +0200 Subject: Remove non-const Sequence::begin()/end() in internal code ... to avoid hidden cost of multiple COW checks, because they call getArray() internally. This obsoletes [loplugin:sequenceloop]. Also rename toNonConstRange to asNonConstRange, to reflect that the result is a view of the sequence, not an independent object. TODO: also drop non-const operator[], but introduce operator[] in SequenceRange. Change-Id: Idd5fd7a3400fe65274d2a6343025e2ef8911635d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123518 Tested-by: Jenkins Reviewed-by: Stephan Bergmann Reviewed-by: Mike Kaganski --- reportdesign/source/core/api/ReportDefinition.cxx | 7 ++++--- reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx | 2 +- reportdesign/source/ui/report/ReportSection.cxx | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'reportdesign/source') diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index f296561bf62e..82776672d8ee 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -443,7 +443,7 @@ void SAL_CALL OStyle::setPropertiesToDefault( const uno::Sequence< OUString >& a uno::Sequence< uno::Any > SAL_CALL OStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) { uno::Sequence< uno::Any > aRet(aPropertyNames.getLength()); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.getArray(), [this](const OUString& rName) -> uno::Any { return getPropertyDefault(rName); }); return aRet; } @@ -1512,8 +1512,9 @@ bool OReportDefinition::WriteThroughComponent( // prepare arguments (prepend doc handler to given arguments) uno::Sequence aArgs( 1 + rArguments.getLength() ); - aArgs[0] <<= xSaxWriter; - std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin())); + auto pArgs = aArgs.getArray(); + *pArgs <<= xSaxWriter; + std::copy(rArguments.begin(), rArguments.end(), std::next(pArgs)); // get filter component uno::Reference< document::XExporter > xExporter( diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx index 933b00dc2fe0..3d8b2c1be603 100644 --- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx @@ -261,7 +261,7 @@ void SAL_CALL ImportDocumentHandler::startElement(const OUString & _sName, const break; } } - for(beans::PropertyValue & propVal : m_aArguments) + for(beans::PropertyValue & propVal : asNonConstRange(m_aArguments)) { if ( propVal.Name == "HasCategories" ) { diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 056951c82216..d757fce2de3d 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -759,7 +759,7 @@ sal_Int8 OReportSection::ExecuteDrop( const ExecuteDropEvent& _rEvt ) else aValues = svx::OMultiColumnTransferable::extractDescriptor(aDropped); - for(beans::PropertyValue & propVal : aValues) + for(beans::PropertyValue & propVal : asNonConstRange(aValues)) { uno::Sequence aCurrent; propVal.Value >>= aCurrent; -- cgit