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>
This commit is contained in:
committed by
Noel Grandin
parent
b83a8483a1
commit
18715f6a63
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
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 aIt = std::find( aElementNames.begin(), aElementNames.end(), rPreferredName );
|
||||
if( aIt == aElementNames.end())
|
||||
aUniqueName = rPreferredName;
|
||||
}
|
||||
else
|
||||
// element found => return name
|
||||
return *aIt;
|
||||
|
||||
if( aUniqueName.isEmpty())
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
OSL_ASSERT( !aUniqueName.isEmpty());
|
||||
xNameContainer->insertByName( aUniqueName, rValue );
|
||||
return aUniqueName;
|
||||
}
|
||||
catch( const uno::Exception & )
|
||||
{
|
||||
|
||||
@@ -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() )
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user