diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-14 09:25:24 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-15 10:36:36 +0200 |
commit | 2484de6728bd11bb7949003d112f1ece2223c7a1 (patch) | |
tree | 1296534e396da284b38d2c478dcd2b31c4714179 /reportdesign | |
parent | 88375fd36899d21d3309cf8333712e02a87d3a91 (diff) |
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 <sbergman@redhat.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'reportdesign')
-rw-r--r-- | reportdesign/source/core/api/ReportDefinition.cxx | 7 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportSection.cxx | 2 |
3 files changed, 6 insertions, 5 deletions
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<uno::Any> 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<beans::PropertyValue> aCurrent; propVal.Value >>= aCurrent; |