From 458e3f67c038d405826eb831bfc0f2aed78f640e Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 29 Jun 2020 17:08:11 +0300 Subject: Small refactor Change-Id: I14021d3e0b83dcd4fb5544239e982c8ada32d029 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97429 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- canvas/source/factory/cf_service.cxx | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'canvas') diff --git a/canvas/source/factory/cf_service.cxx b/canvas/source/factory/cf_service.cxx index 936c99885f20..874b1ffe68bf 100644 --- a/canvas/source/factory/cf_service.cxx +++ b/canvas/source/factory/cf_service.cxx @@ -368,19 +368,15 @@ Reference CanvasFactory::lookupAndUse( } const Sequence aPreferredImpls( aAvailImplsMatch->second ); - const OUString* pCurrImpl = aPreferredImpls.getConstArray(); - const OUString* const pEndImpl = pCurrImpl + aPreferredImpls.getLength(); + const OUString* pCurrImpl = aPreferredImpls.begin(); + const OUString* const pEndImpl = aPreferredImpls.end(); const Sequence aAAImpls( aAAImplsMatch->second ); - const OUString* const pFirstAAImpl = aAAImpls.getConstArray(); - const OUString* const pEndAAImpl = pFirstAAImpl + aAAImpls.getLength(); const Sequence aAccelImpls( aAccelImplsMatch->second ); - const OUString* const pFirstAccelImpl = aAccelImpls.getConstArray(); - const OUString* const pEndAccelImpl = pFirstAccelImpl + aAccelImpls.getLength(); // force last entry from impl list, if config flag set - if( bForceLastEntry ) + if (bForceLastEntry && pCurrImpl != pEndImpl) pCurrImpl = pEndImpl-1; while( pCurrImpl != pEndImpl ) @@ -390,8 +386,7 @@ Reference CanvasFactory::lookupAndUse( // check whether given canvas service is listed in the // sequence of "accelerated canvas implementations" const bool bIsAcceleratedImpl( - std::any_of(pFirstAccelImpl, - pEndAccelImpl, + std::any_of(aAccelImpls.begin(), aAccelImpls.end(), [&aCurrName](OUString const& src) { return aCurrName == src.trim(); } )); @@ -399,8 +394,7 @@ Reference CanvasFactory::lookupAndUse( // check whether given canvas service is listed in the // sequence of "antialiasing canvas implementations" const bool bIsAAImpl( - std::any_of(pFirstAAImpl, - pEndAAImpl, + std::any_of(aAAImpls.begin(), aAAImpls.end(), [&aCurrName](OUString const& src) { return aCurrName == src.trim(); } )); @@ -413,8 +407,7 @@ Reference CanvasFactory::lookupAndUse( // http://en.wikipedia.org/wiki/Truth_table#Logical_implication if( (!bIsAAImpl || bUseAAEntry) && (!bIsAcceleratedImpl || bUseAcceleratedEntry) ) { - Reference xCanvas( - use( pCurrImpl->trim(), args, xContext ) ); + Reference xCanvas(use(aCurrName, args, xContext)); if(xCanvas.is()) { @@ -422,13 +415,12 @@ Reference CanvasFactory::lookupAndUse( { // cache entry exists, replace dysfunctional // implementation name - aMatch->second = pCurrImpl->trim(); + aMatch->second = aCurrName; } else { // new service name, add new cache entry - m_aCachedImplementations.emplace_back(serviceName, - pCurrImpl->trim()); + m_aCachedImplementations.emplace_back(serviceName, aCurrName); } return xCanvas; -- cgit