Small refactor

Change-Id: I14021d3e0b83dcd4fb5544239e982c8ada32d029
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97429
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2020-06-29 17:08:11 +03:00
parent 14e625e0a0
commit 458e3f67c0

View File

@@ -368,19 +368,15 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
} }
const Sequence<OUString> aPreferredImpls( aAvailImplsMatch->second ); const Sequence<OUString> aPreferredImpls( aAvailImplsMatch->second );
const OUString* pCurrImpl = aPreferredImpls.getConstArray(); const OUString* pCurrImpl = aPreferredImpls.begin();
const OUString* const pEndImpl = pCurrImpl + aPreferredImpls.getLength(); const OUString* const pEndImpl = aPreferredImpls.end();
const Sequence<OUString> aAAImpls( aAAImplsMatch->second ); const Sequence<OUString> aAAImpls( aAAImplsMatch->second );
const OUString* const pFirstAAImpl = aAAImpls.getConstArray();
const OUString* const pEndAAImpl = pFirstAAImpl + aAAImpls.getLength();
const Sequence<OUString> aAccelImpls( aAccelImplsMatch->second ); const Sequence<OUString> 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 // force last entry from impl list, if config flag set
if( bForceLastEntry ) if (bForceLastEntry && pCurrImpl != pEndImpl)
pCurrImpl = pEndImpl-1; pCurrImpl = pEndImpl-1;
while( pCurrImpl != pEndImpl ) while( pCurrImpl != pEndImpl )
@@ -390,8 +386,7 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
// check whether given canvas service is listed in the // check whether given canvas service is listed in the
// sequence of "accelerated canvas implementations" // sequence of "accelerated canvas implementations"
const bool bIsAcceleratedImpl( const bool bIsAcceleratedImpl(
std::any_of(pFirstAccelImpl, std::any_of(aAccelImpls.begin(), aAccelImpls.end(),
pEndAccelImpl,
[&aCurrName](OUString const& src) [&aCurrName](OUString const& src)
{ return aCurrName == src.trim(); } { return aCurrName == src.trim(); }
)); ));
@@ -399,8 +394,7 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
// check whether given canvas service is listed in the // check whether given canvas service is listed in the
// sequence of "antialiasing canvas implementations" // sequence of "antialiasing canvas implementations"
const bool bIsAAImpl( const bool bIsAAImpl(
std::any_of(pFirstAAImpl, std::any_of(aAAImpls.begin(), aAAImpls.end(),
pEndAAImpl,
[&aCurrName](OUString const& src) [&aCurrName](OUString const& src)
{ return aCurrName == src.trim(); } { return aCurrName == src.trim(); }
)); ));
@@ -413,8 +407,7 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
// http://en.wikipedia.org/wiki/Truth_table#Logical_implication // http://en.wikipedia.org/wiki/Truth_table#Logical_implication
if( (!bIsAAImpl || bUseAAEntry) && (!bIsAcceleratedImpl || bUseAcceleratedEntry) ) if( (!bIsAAImpl || bUseAAEntry) && (!bIsAcceleratedImpl || bUseAcceleratedEntry) )
{ {
Reference<XInterface> xCanvas( Reference<XInterface> xCanvas(use(aCurrName, args, xContext));
use( pCurrImpl->trim(), args, xContext ) );
if(xCanvas.is()) if(xCanvas.is())
{ {
@@ -422,13 +415,12 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
{ {
// cache entry exists, replace dysfunctional // cache entry exists, replace dysfunctional
// implementation name // implementation name
aMatch->second = pCurrImpl->trim(); aMatch->second = aCurrName;
} }
else else
{ {
// new service name, add new cache entry // new service name, add new cache entry
m_aCachedImplementations.emplace_back(serviceName, m_aCachedImplementations.emplace_back(serviceName, aCurrName);
pCurrImpl->trim());
} }
return xCanvas; return xCanvas;