summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-14 09:25:24 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-15 10:36:36 +0200
commit2484de6728bd11bb7949003d112f1ece2223c7a1 (patch)
tree1296534e396da284b38d2c478dcd2b31c4714179 /vcl
parent88375fd36899d21d3309cf8333712e02a87d3a91 (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 'vcl')
-rw-r--r--vcl/qa/cppunit/canvasbitmaptest.cxx6
-rw-r--r--vcl/qt5/QtAccessibleWidget.cxx2
-rw-r--r--vcl/source/filter/graphicfilter.cxx6
-rw-r--r--vcl/source/gdi/configsettings.cxx2
-rw-r--r--vcl/source/gdi/print3.cxx2
-rw-r--r--vcl/source/gdi/vectorgraphicdata.cxx9
-rw-r--r--vcl/source/graphic/UnoGraphic.cxx2
-rw-r--r--vcl/source/uitest/uitest.cxx2
-rw-r--r--vcl/unx/generic/dtrans/X11_transferable.cxx2
9 files changed, 17 insertions, 16 deletions
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index 9b50282ee8b0..10923d8704f2 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -499,7 +499,7 @@ private:
{
const uno::Sequence< rendering::ARGBColor > aTemp( convertIntegerToARGB(deviceColor) );
uno::Sequence< rendering::RGBColor > aRes( aTemp.getLength() );
- std::transform(aTemp.begin(), aTemp.end(), aRes.begin(),
+ std::transform(aTemp.begin(), aTemp.end(), aRes.getArray(),
[](const rendering::ARGBColor& rColor) {
return rendering::RGBColor(rColor.Red,
rColor.Green,
@@ -520,7 +520,7 @@ private:
if( getPalette().is() )
{
- std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(),
+ std::transform(deviceColor.begin(), deviceColor.end(), aRes.getArray(),
[](sal_Int8 nIn) {
auto fColor = vcl::unotools::toDoubleColor(nIn);
return rendering::ARGBColor(1.0, fColor, fColor, fColor);
@@ -554,7 +554,7 @@ private:
if( getPalette().is() )
{
- std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(),
+ std::transform(deviceColor.begin(), deviceColor.end(), aRes.getArray(),
[](sal_Int8 nIn) {
auto fColor = vcl::unotools::toDoubleColor(nIn);
return rendering::ARGBColor(1.0, fColor, fColor, fColor);
diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index 9f5b6ced8808..ed639b524028 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -702,7 +702,7 @@ QAccessible::State QtAccessibleWidget::state() const
if (!xStateSet.is())
return state;
- Sequence<sal_Int16> aStates = xStateSet->getStates();
+ const Sequence<sal_Int16> aStates = xStateSet->getStates();
for (const sal_Int16 nState : aStates)
{
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 8bacefd777d8..24c1ccd66000 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1054,7 +1054,7 @@ ErrCode GraphicFilter::readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkTy
{
VectorGraphicDataArray aNewData(nMemoryLength);
aMemStream.Seek(STREAM_SEEK_TO_BEGIN);
- aMemStream.ReadBytes(aNewData.begin(), nMemoryLength);
+ aMemStream.ReadBytes(aNewData.getArray(), nMemoryLength);
// Make a uncompressed copy for GfxLink
rGraphicContentSize = nMemoryLength;
@@ -1073,7 +1073,7 @@ ErrCode GraphicFilter::readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkTy
else
{
VectorGraphicDataArray aNewData(nStreamLength);
- rStream.ReadBytes(aNewData.begin(), nStreamLength);
+ rStream.ReadBytes(aNewData.getArray(), nStreamLength);
if (!rStream.GetError())
{
@@ -1125,7 +1125,7 @@ ErrCode GraphicFilter::readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLi
const sal_uInt32 nStreamLength(rStream.remainingSize());
VectorGraphicDataArray aNewData(nStreamLength);
- rStream.ReadBytes(aNewData.begin(), nStreamLength);
+ rStream.ReadBytes(aNewData.getArray(), nStreamLength);
if (!rStream.GetError())
{
diff --git a/vcl/source/gdi/configsettings.cxx b/vcl/source/gdi/configsettings.cxx
index 67e3b89ebfcc..5586f67a610a 100644
--- a/vcl/source/gdi/configsettings.cxx
+++ b/vcl/source/gdi/configsettings.cxx
@@ -95,7 +95,7 @@ void SettingsConfigItem::getValues()
#endif
const Sequence< OUString > aKeys( GetNodeNames( aKeyName ) );
Sequence< OUString > aSettingsKeys( aKeys.getLength() );
- std::transform(aKeys.begin(), aKeys.end(), aSettingsKeys.begin(),
+ std::transform(aKeys.begin(), aKeys.end(), aSettingsKeys.getArray(),
[&aKeyName](const OUString& rKey) -> OUString { return aKeyName + "/" + rKey; });
const Sequence< Any > aValues( GetProperties( aSettingsKeys ) );
for( int i = 0; i < aValues.getLength(); i++ )
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 620a00f6e145..dc48e55efa94 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -1456,7 +1456,7 @@ css::uno::Sequence< css::beans::PropertyValue > PrinterController::getJobPropert
aMergeSet.insert( rPropVal.Name );
css::uno::Sequence< css::beans::PropertyValue > aResult( nResultLen );
- std::copy(i_rMergeList.begin(), i_rMergeList.end(), aResult.begin());
+ std::copy(i_rMergeList.begin(), i_rMergeList.end(), aResult.getArray());
int nCur = i_rMergeList.getLength();
for(const css::beans::PropertyValue & rPropVal : mpImplData->maUIProperties)
{
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index bf8f3b508ff6..3bf729d65418 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -206,7 +206,7 @@ void VectorGraphicData::ensureSequenceAndRange()
case VectorGraphicDataType::Svg:
{
css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize());
- std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin());
+ std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.getArray());
const uno::Reference<io::XInputStream> xInputStream(new comphelper::SequenceInputStream(aDataSequence));
@@ -223,7 +223,7 @@ void VectorGraphicData::ensureSequenceAndRange()
const uno::Reference< graphic::XEmfParser > xEmfParser = graphic::EmfTools::create(xContext);
css::uno::Sequence<sal_Int8> aDataSequence(maDataContainer.getSize());
- std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.begin());
+ std::copy(maDataContainer.cbegin(), maDataContainer.cend(), aDataSequence.getArray());
const uno::Reference<io::XInputStream> xInputStream(new comphelper::SequenceInputStream(aDataSequence));
uno::Sequence< ::beans::PropertyValue > aPropertySequence;
@@ -336,11 +336,12 @@ VectorGraphicData::VectorGraphicData(
if (nStmLen)
{
VectorGraphicDataArray aVectorGraphicDataArray(nStmLen);
- rIStm.ReadBytes(aVectorGraphicDataArray.begin(), nStmLen);
+ auto pData = aVectorGraphicDataArray.getArray();
+ rIStm.ReadBytes(pData, nStmLen);
if (!rIStm.GetError())
{
- maDataContainer = BinaryDataContainer(reinterpret_cast<const sal_uInt8*>(aVectorGraphicDataArray.begin()), aVectorGraphicDataArray.getLength());
+ maDataContainer = BinaryDataContainer(reinterpret_cast<const sal_uInt8*>(pData), nStmLen);
}
}
}
diff --git a/vcl/source/graphic/UnoGraphic.cxx b/vcl/source/graphic/UnoGraphic.cxx
index fde322d94b7e..e415de1523d3 100644
--- a/vcl/source/graphic/UnoGraphic.cxx
+++ b/vcl/source/graphic/UnoGraphic.cxx
@@ -102,7 +102,7 @@ uno::Sequence< OUString > SAL_CALL Graphic::getSupportedServiceNames()
aRet.realloc( nOldCount + aNew.getLength() );
- std::copy(aNew.begin(), aNew.end(), std::next(aRet.begin(), nOldCount));
+ std::copy(aNew.begin(), aNew.end(), std::next(aRet.getArray(), nOldCount));
return aRet;
}
diff --git a/vcl/source/uitest/uitest.cxx b/vcl/source/uitest/uitest.cxx
index 1c5a989d67d8..f52e636f5081 100644
--- a/vcl/source/uitest/uitest.cxx
+++ b/vcl/source/uitest/uitest.cxx
@@ -39,7 +39,7 @@ bool UITest::executeCommandWithParameters(const OUString& rCommand,
sal_uInt32 nIndex( lNewArgs.getLength() );
lNewArgs.realloc( lNewArgs.getLength()+rArgs.getLength() );
- std::copy(rArgs.begin(), rArgs.end(), std::next(lNewArgs.begin(), nIndex));
+ std::copy(rArgs.begin(), rArgs.end(), std::next(lNewArgs.getArray(), nIndex));
}
return comphelper::dispatchCommand(rCommand,lNewArgs);
}
diff --git a/vcl/unx/generic/dtrans/X11_transferable.cxx b/vcl/unx/generic/dtrans/X11_transferable.cxx
index 1310f70bc234..a6ad1b4a15da 100644
--- a/vcl/unx/generic/dtrans/X11_transferable.cxx
+++ b/vcl/unx/generic/dtrans/X11_transferable.cxx
@@ -90,7 +90,7 @@ sal_Bool SAL_CALL X11Transferable::isDataFlavorSupported( const DataFlavor& aFla
return false;
}
- Sequence< DataFlavor > aFlavors( getTransferDataFlavors() );
+ const Sequence< DataFlavor > aFlavors( getTransferDataFlavors() );
return std::any_of(aFlavors.begin(), aFlavors.end(),
[&aFlavor](const DataFlavor& rFlavor) {
return aFlavor.MimeType.equalsIgnoreAsciiCase( rFlavor.MimeType )