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 /vbahelper | |
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 'vbahelper')
-rw-r--r-- | vbahelper/source/msforms/vbalistcontrolhelper.cxx | 2 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbahelper.cxx | 9 |
2 files changed, 5 insertions, 6 deletions
diff --git a/vbahelper/source/msforms/vbalistcontrolhelper.cxx b/vbahelper/source/msforms/vbalistcontrolhelper.cxx index 8f3ff6b45601..d8ea543bf4ca 100644 --- a/vbahelper/source/msforms/vbalistcontrolhelper.cxx +++ b/vbahelper/source/msforms/vbalistcontrolhelper.cxx @@ -125,7 +125,7 @@ ListControlHelper::AddItem( const uno::Any& pvargItem, const uno::Any& pvargInde sList.realloc( sList.getLength() + 1 ); // point at first element to be overwritten - std::copy(sVec.begin(), sVec.end(), std::next(sList.begin(), nIndex)); + std::copy(sVec.begin(), sVec.end(), std::next(sList.getArray(), nIndex)); } m_xProps->setPropertyValue( "StringItemList", uno::makeAny( sList ) ); diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 2eaa7e9f5a38..9ed61ba32685 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -152,13 +152,12 @@ dispatchRequests (const uno::Reference< frame::XModel>& xModel, const OUString & uno::Reference<frame::XDispatch> xDispatcher = xDispatchProvider->queryDispatch(url,"",0); - uno::Sequence<beans::PropertyValue> dispatchProps(1); - sal_Int32 nProps = sProps.getLength(); + uno::Sequence<beans::PropertyValue> dispatchProps(nProps + 1); + if ( nProps ) { - dispatchProps.realloc( nProps + 1 ); - std::copy(sProps.begin(), sProps.end(), dispatchProps.begin()); + std::copy(sProps.begin(), sProps.end(), dispatchProps.getArray()); } if ( xDispatcher.is() ) @@ -734,7 +733,7 @@ uno::Any getPropertyValue( const uno::Sequence< beans::PropertyValue >& aProp, c bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const OUString& aName, const uno::Any& aValue ) { - auto [begin, end] = toNonConstRange(aProp); + auto [begin, end] = asNonConstRange(aProp); auto pProp = std::find_if(begin, end, [&aName](const beans::PropertyValue& rProp) { return rProp.Name == aName; }); if (pProp != end) |