diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-05-06 19:57:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-06 21:52:00 +0200 |
commit | 18715f6a63af55045b108b98abeffeae8e51518b (patch) | |
tree | 7cfcc6fc8a27c6f0c023d74fac5e43b88ac70907 | |
parent | b83a8483a1426ba400480d33f7df321fcc02e64d (diff) |
remove unnecessary sequenceToContainer
If we are not going to manipulate the resulting vector, then it is
actually slower, since we have to allocate more storage for the vector
Change-Id: I65677007d105f4783603df74113ebed6db0b551b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133963
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 5 | ||||
-rw-r--r-- | chart2/source/tools/DataSeriesHelper.cxx | 5 | ||||
-rw-r--r-- | chart2/source/tools/PropertyHelper.cxx | 76 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 4 | ||||
-rw-r--r-- | sccomp/source/solver/CoinMPSolver.cxx | 2 | ||||
-rw-r--r-- | sccomp/source/solver/LpsolveSolver.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 3 | ||||
-rw-r--r-- | stoc/source/simpleregistry/simpleregistry.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLTableContext.cxx | 12 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xmlsignaturehelper.cxx | 7 |
13 files changed, 65 insertions, 73 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index dc667a4fbbca..09ee8b6a28b7 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1067,9 +1067,8 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) { if( bIsPoint ) { - auto aIndices( comphelper::sequenceToContainer<std::vector< sal_Int32 >>( aAttributedDataPointIndexList ) ); - std::vector< sal_Int32 >::iterator aIt = std::find( aIndices.begin(), aIndices.end(), nPointIndex ); - if( aIt != aIndices.end()) + auto aIt = std::find( std::as_const(aAttributedDataPointIndexList).begin(), std::as_const(aAttributedDataPointIndexList).end(), nPointIndex ); + if( aIt != std::as_const(aAttributedDataPointIndexList).end()) bSelectedPointIsFormatted = true; else bHasFormattedDataPointsOtherThanSelected = true; diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index bff4032f16d3..a4b4dec45ad0 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -805,9 +805,8 @@ bool hasDataLabelAtPoint( const Reference< chart2::XDataSeries >& xSeries, sal_I uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) { - auto aIndices( comphelper::sequenceToContainer<std::vector< sal_Int32 >>( aAttributedDataPointIndexList ) ); - std::vector< sal_Int32 >::iterator aIt = std::find( aIndices.begin(), aIndices.end(), nPointIndex ); - if( aIt != aIndices.end()) + auto aIt = std::find( std::as_const(aAttributedDataPointIndexList).begin(), std::as_const(aAttributedDataPointIndexList).end(), nPointIndex ); + if( aIt != std::as_const(aAttributedDataPointIndexList).end()) xProp = xSeries->getDataPointByIndex(nPointIndex); else xProp = xSeriesProperties; diff --git a/chart2/source/tools/PropertyHelper.cxx b/chart2/source/tools/PropertyHelper.cxx index 4cff29e40d17..9f34ba1c2d70 100644 --- a/chart2/source/tools/PropertyHelper.cxx +++ b/chart2/source/tools/PropertyHelper.cxx @@ -119,49 +119,47 @@ OUString lcl_addNamedPropertyUniqueNameToTable( try { Reference< container::XNameAccess > xNameAccess( xNameContainer, uno::UNO_QUERY_THROW ); - auto aNames( comphelper::sequenceToContainer<std::vector< OUString >>( xNameAccess->getElementNames())); - std::vector< OUString >::const_iterator aIt( - std::find_if( aNames.begin(), aNames.end(), lcl_EqualsElement( rValue, xNameAccess ))); + const uno::Sequence<OUString> aElementNames = xNameAccess->getElementNames(); + auto it = std::find_if( aElementNames.begin(), aElementNames.end(), lcl_EqualsElement( rValue, xNameAccess )); + + // element found => return name + if( it != aElementNames.end()) + return *it; // element not found in container - if( aIt == aNames.end()) + OUString aUniqueName; + + // check if preferred name is already used + if( !rPreferredName.isEmpty()) + { + auto aIt = std::find( aElementNames.begin(), aElementNames.end(), rPreferredName ); + if( aIt == aElementNames.end()) + aUniqueName = rPreferredName; + } + + if( aUniqueName.isEmpty()) { - OUString aUniqueName; - - // check if preferred name is already used - if( !rPreferredName.isEmpty()) - { - aIt = std::find( aNames.begin(), aNames.end(), rPreferredName ); - if( aIt == aNames.end()) - aUniqueName = rPreferredName; - } - - if( aUniqueName.isEmpty()) - { - // create a unique id using the prefix plus a number - std::vector< sal_Int32 > aNumbers; - std::vector< OUString >::iterator aNonConstIt( - std::partition( aNames.begin(), aNames.end(), lcl_StringMatches( rPrefix ))); - std::transform( aNames.begin(), aNonConstIt, - back_inserter( aNumbers ), - lcl_OUStringRestToInt32( rPrefix.getLength() )); - std::vector< sal_Int32 >::const_iterator aMaxIt( - std::max_element( aNumbers.begin(), aNumbers.end())); - - sal_Int32 nIndex = 1; - if( aMaxIt != aNumbers.end()) - nIndex = (*aMaxIt) + 1; - - aUniqueName = rPrefix + OUString::number( nIndex ); - } - - OSL_ASSERT( !aUniqueName.isEmpty()); - xNameContainer->insertByName( aUniqueName, rValue ); - return aUniqueName; + auto aNames( comphelper::sequenceToContainer<std::vector< OUString >>( aElementNames )); + // create a unique id using the prefix plus a number + std::vector< sal_Int32 > aNumbers; + std::vector< OUString >::iterator aNonConstIt( + std::partition( aNames.begin(), aNames.end(), lcl_StringMatches( rPrefix ))); + std::transform( aNames.begin(), aNonConstIt, + back_inserter( aNumbers ), + lcl_OUStringRestToInt32( rPrefix.getLength() )); + std::vector< sal_Int32 >::const_iterator aMaxIt( + std::max_element( aNumbers.begin(), aNumbers.end())); + + sal_Int32 nIndex = 1; + if( aMaxIt != aNumbers.end()) + nIndex = (*aMaxIt) + 1; + + aUniqueName = rPrefix + OUString::number( nIndex ); } - else - // element found => return name - return *aIt; + + OSL_ASSERT( !aUniqueName.isEmpty()); + xNameContainer->insertByName( aUniqueName, rValue ); + return aUniqueName; } catch( const uno::Exception & ) { diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index f4763dfa7c5d..b4b9de8fb9c6 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -784,8 +784,8 @@ namespace sax_fastparser { void FastSaxSerializer::ForSort::setCurrentElement( sal_Int32 nElement ) { - vector< sal_Int32 > aOrder( comphelper::sequenceToContainer<vector<sal_Int32> >(maOrder) ); - if( std::find( aOrder.begin(), aOrder.end(), nElement ) != aOrder.end() ) + const auto & rOrder = maOrder; + if( std::find( rOrder.begin(), rOrder.end(), nElement ) != rOrder.end() ) { mnCurrentElement = nElement; if ( maData.find( nElement ) == maData.end() ) diff --git a/sccomp/source/solver/CoinMPSolver.cxx b/sccomp/source/solver/CoinMPSolver.cxx index 35ebf1fd19b2..a6b423d2d4a2 100644 --- a/sccomp/source/solver/CoinMPSolver.cxx +++ b/sccomp/source/solver/CoinMPSolver.cxx @@ -67,7 +67,7 @@ void SAL_CALL CoinMPSolver::solve() // collect variables in vector (?) - auto aVariableCells = comphelper::sequenceToContainer<std::vector<table::CellAddress>>(maVariables); + const auto & aVariableCells = maVariables; size_t nVariables = aVariableCells.size(); size_t nVar = 0; diff --git a/sccomp/source/solver/LpsolveSolver.cxx b/sccomp/source/solver/LpsolveSolver.cxx index 270840453c9e..78cd25e81167 100644 --- a/sccomp/source/solver/LpsolveSolver.cxx +++ b/sccomp/source/solver/LpsolveSolver.cxx @@ -103,7 +103,7 @@ void SAL_CALL LpsolveSolver::solve() // collect variables in vector (?) - auto aVariableCells = comphelper::sequenceToContainer<std::vector<table::CellAddress>>(maVariables); + const auto & aVariableCells = maVariables; size_t nVariables = aVariableCells.size(); size_t nVar = 0; diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 23856a34401b..63e787be6b4c 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1493,8 +1493,7 @@ void SAL_CALL SfxBaseController::appendInfobar(const OUString& sId, const OUStri if (!pInfoBar) throw uno::RuntimeException("Could not create Infobar"); - auto vActionButtons = comphelper::sequenceToContainer<std::vector<StringPair>>(actionButtons); - for (auto& actionButton : vActionButtons) + for (const StringPair & actionButton : std::as_const(actionButtons)) { if (actionButton.First.isEmpty() || actionButton.Second.isEmpty()) continue; diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx index 0b7fae2b8641..6291889a3733 100644 --- a/stoc/source/simpleregistry/simpleregistry.cxx +++ b/stoc/source/simpleregistry/simpleregistry.cxx @@ -315,9 +315,8 @@ css::uno::Sequence< sal_Int32 > Key::getLongListValue() void Key::setLongListValue(css::uno::Sequence< sal_Int32 > const & seqValue) { std::scoped_lock guard(registry_->mutex_); - auto list = comphelper::sequenceToContainer<std::vector<sal_Int32>>(seqValue); RegError err = key_.setLongListValue( - OUString(), list.data(), static_cast< sal_uInt32 >(list.size())); + OUString(), seqValue.getConstArray(), static_cast< sal_uInt32 >(seqValue.getLength())); if (err != RegError::NO_ERROR) { throw css::registry::InvalidRegistryException( "com.sun.star.registry.SimpleRegistry key setLongListValue:" diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 5333764798e5..ff29c1f10c83 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -1789,14 +1789,13 @@ void SwEditShell::SignParagraph() const OUString signature = OStringToOUString(sigBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8, 0); - std::vector<css::beans::PropertyValue> vec = comphelper::sequenceToContainer<std::vector<css::beans::PropertyValue>>(aProperties); - auto it = std::find_if(vec.begin(), vec.end(), [](const beans::PropertyValue& rValue) + auto it = std::find_if(std::as_const(aProperties).begin(), std::as_const(aProperties).end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "Usage"; }); OUString aUsage; - if (it != vec.end()) + if (it != std::as_const(aProperties).end()) it->Value >>= aUsage; // 4. Add metadata diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 355770e4e1c1..5e323ee6b937 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -1286,12 +1286,12 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons m_pImpl->getSerializer()->startElementNS(XML_wp, XML_wrapPolygon, XML_edited, "0"); auto aSeqSeq = it->second.get<drawing::PointSequenceSequence>(); - auto aPoints(comphelper::sequenceToContainer<std::vector<awt::Point>>(aSeqSeq[0])); - for (auto i = aPoints.begin(); i != aPoints.end(); ++i) + const auto& rPoints = aSeqSeq[0]; + for (auto i = rPoints.begin(); i != rPoints.end(); ++i) { - awt::Point& rPoint = *i; + const awt::Point& rPoint = *i; m_pImpl->getSerializer()->singleElementNS( - XML_wp, (i == aPoints.begin() ? XML_start : XML_lineTo), XML_x, + XML_wp, (i == rPoints.begin() ? XML_start : XML_lineTo), XML_x, OString::number(rPoint.X), XML_y, OString::number(rPoint.Y)); } m_pImpl->getSerializer()->endElementNS(XML_wp, XML_wrapPolygon); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 9537c5a65786..9f3ac5f2c096 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2173,8 +2173,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con { uno::Sequence<beans::PropertyValue> aPrevPropertiesSeq; m_xPreviousParagraph->getPropertyValue("ParaInteropGrabBag") >>= aPrevPropertiesSeq; - auto aPrevProperties = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aPrevPropertiesSeq); - bool bParaAutoBefore = m_bParaAutoBefore || std::any_of(aPrevProperties.begin(), aPrevProperties.end(), [](const beans::PropertyValue& rValue) + const auto & rPrevProperties = aPrevPropertiesSeq; + bool bParaAutoBefore = m_bParaAutoBefore || std::any_of(rPrevProperties.begin(), rPrevProperties.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "ParaTopMarginBeforeAutoSpacing"; }); @@ -2202,7 +2202,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con aProperties.push_back(comphelper::makePropertyValue("ParaTopMargin", static_cast<sal_Int32>(0))); } - bool bPrevParaAutoAfter = std::any_of(aPrevProperties.begin(), aPrevProperties.end(), [](const beans::PropertyValue& rValue) + bool bPrevParaAutoAfter = std::any_of(rPrevProperties.begin(), rPrevProperties.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "ParaBottomMarginAfterAutoSpacing"; }); diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index 6e5e7f068b01..61eb6c400c13 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -277,9 +277,9 @@ void SchXMLTableContext::endFastElement(sal_Int32 ) if( mbHasColumnPermutation ) { SAL_WARN_IF( mbHasRowPermutation, "xmloff.chart", "mbHasColumnPermutation is true" ); - auto aPermutation( comphelper::sequenceToContainer<std::vector< sal_Int32 >>( maColumnPermutation )); - SAL_WARN_IF( aPermutation.empty(), "xmloff.chart", "aPermutation is NULL"); - if( aPermutation.empty()) + const auto & aPermutation( maColumnPermutation ); + SAL_WARN_IF( !aPermutation.hasElements(), "xmloff.chart", "aPermutation is NULL"); + if( !aPermutation.hasElements()) return; // permute the values of all rows according to aPermutation @@ -316,9 +316,9 @@ void SchXMLTableContext::endFastElement(sal_Int32 ) } else if( mbHasRowPermutation ) { - auto aPermutation( comphelper::sequenceToContainer<std::vector< sal_Int32 >>( maRowPermutation )); - SAL_WARN_IF( aPermutation.empty(), "xmloff.chart", "aPermutation is NULL"); - if( aPermutation.empty()) + const auto & aPermutation( maRowPermutation ); + SAL_WARN_IF( !aPermutation.hasElements(), "xmloff.chart", "aPermutation is NULL"); + if( !aPermutation.hasElements()) return; bool bModified = false; diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 6436f9f7c627..0d9755d0ebe1 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -335,11 +335,10 @@ bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const uno::Reference<embe for (sal_Int32 i = 0; i < aRelationsInfo.getLength(); ++i) { const uno::Sequence<beans::StringPair>& rRelation = aRelationsInfo[i]; - auto aRelation = comphelper::sequenceToContainer< std::vector<beans::StringPair> >(rRelation); - if (std::any_of(aRelation.begin(), aRelation.end(), lcl_isSignatureType)) + if (std::any_of(rRelation.begin(), rRelation.end(), lcl_isSignatureType)) { - std::vector<beans::StringPair>::iterator it = std::find_if(aRelation.begin(), aRelation.end(), [](const beans::StringPair& rPair) { return rPair.First == "Target"; }); - if (it != aRelation.end()) + auto it = std::find_if(rRelation.begin(), rRelation.end(), [](const beans::StringPair& rPair) { return rPair.First == "Target"; }); + if (it != rRelation.end()) { if (xStorage.is() && !xStorage->hasByName(it->Second)) { |