tdf#158237: Use C++20 contains() instead of find() and end()

Change-Id: I0528229042aa62d3d99e8dbaad68a86d41cf369a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178659
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Johann
2024-12-27 16:20:47 +01:00
committed by Ilmari Lauhakangas
parent d2d9af8658
commit bf7ac07c04
19 changed files with 23 additions and 23 deletions
+1 -1
View File
@@ -246,7 +246,7 @@ Sequence<OUString> ComponentContext::getElementNames()
sal_Bool ComponentContext::hasByName( OUString const & name )
{
std::unique_lock guard( m_aMutex );
return m_map.find( name ) != m_map.end();
return m_map.contains( name );
}
// XElementAccess
+1 -1
View File
@@ -7693,7 +7693,7 @@ static void lo_setDocumentPassword(LibreOfficeKit* pThis,
assert(pThis);
assert(pURL);
LibLibreOffice_Impl *const pLib = static_cast<LibLibreOffice_Impl*>(pThis);
assert(pLib->mInteractionMap.find(OString(pURL)) != pLib->mInteractionMap.end());
assert(pLib->mInteractionMap.contains(OString(pURL)));
pLib->mInteractionMap.find(OString(pURL))->second->SetPassword(pPassword);
}
+1 -1
View File
@@ -321,7 +321,7 @@ void CGMImpressOutAct::ImplSetFillBundle()
drawing::Hatch aHatch;
aHatch.Color = nFillColor;
if ( mpCGM->pElement->maHatchMap.find( nHatchIndex ) != mpCGM->pElement->maHatchMap.end() )
if ( mpCGM->pElement->maHatchMap.contains( nHatchIndex ) )
{
HatchEntry& rHatchEntry = mpCGM->pElement->maHatchMap[ nHatchIndex ];
switch ( rHatchEntry.HatchStyle )
+1 -1
View File
@@ -2222,7 +2222,7 @@ bool SVGFilter::implExportShape( const Reference< css::drawing::XShape >& rxShap
}
const GDIMetaFile* pEmbeddedBitmapsMtf = nullptr;
if( mEmbeddedBitmapActionMap.find( rxShape ) != mEmbeddedBitmapActionMap.end() )
if( mEmbeddedBitmapActionMap.contains( rxShape ) )
{
pEmbeddedBitmapsMtf = &( mEmbeddedBitmapActionMap[ rxShape ].GetRepresentation() );
}
+1 -1
View File
@@ -280,7 +280,7 @@ Convert& Convert::get()
bool Convert::hasType( const css::uno::Type& rType )
{
return maMap.find( rType ) != maMap.end();
return maMap.contains( rType );
}
css::uno::Sequence<css::uno::Type> Convert::getTypes() const
+1 -1
View File
@@ -1789,7 +1789,7 @@ static const GdkRGBA& getDarkColor(int nViewId, LOKDocViewPrivate& priv)
GdkRGBA aColor = aColors[nColorCounter++ % aColors.size()];
aColorMap[nViewId] = aColor;
}
assert(aColorMap.find(nViewId) != aColorMap.end());
assert(aColorMap.contains(nViewId));
return aColorMap[nViewId];
}
+2 -2
View File
@@ -251,7 +251,7 @@ css::uno::Any SAL_CALL LngXStringKeyMap::getValue(const OUString& aKey)
sal_Bool SAL_CALL LngXStringKeyMap::hasValue(const OUString& aKey)
{
return maMap.find(aKey) != maMap.end();
return maMap.contains(aKey);
}
::sal_Int32 SAL_CALL LngXStringKeyMap::getCount() { return maMap.size(); }
@@ -341,7 +341,7 @@ OUString GrammarCheckingIterator::GetOrCreateDocId(
OUString aRes;
if (xComponent.is())
{
if (m_aDocIdMap.find( xComponent.get() ) != m_aDocIdMap.end())
if (m_aDocIdMap.contains( xComponent.get() ))
{
// return already existing entry
aRes = m_aDocIdMap[ xComponent.get() ];
+1 -1
View File
@@ -275,7 +275,7 @@ namespace sd
{
if( xSource.is() )
{
if( maShapeMap.find(xSource) != maShapeMap.end() )
if( maShapeMap.contains(xSource) )
{
return maShapeMap[xSource];
}
+1 -1
View File
@@ -53,7 +53,7 @@ OUString SAL_CALL SaxAttrList::getTypeByIndex( sal_Int16 i_nIndex)
OUString SAL_CALL SaxAttrList::getTypeByName( const OUString& i_rName )
{
return (m_aIndexMap.find( i_rName ) != m_aIndexMap.end()) ? CDATA : OUString();
return (m_aIndexMap.contains( i_rName )) ? CDATA : OUString();
}
OUString SAL_CALL SaxAttrList::getValueByIndex( sal_Int16 i_nIndex )
+2 -2
View File
@@ -140,8 +140,8 @@ CPPUNIT_TEST_FIXTURE(Test, testSetDocumentPropertiesUpdate)
// - Actual : foo
// i.e. ZOTERO_PREF_1 was not updated.
CPPUNIT_ASSERT_EQUAL(u"test"_ustr, it->second.get<OUString>());
CPPUNIT_ASSERT(bool(aMap.find(u"ZOTERO_PREF_2"_ustr) == aMap.end()));
CPPUNIT_ASSERT(aMap.find(u"OTHER"_ustr) != aMap.end());
CPPUNIT_ASSERT(!aMap.contains(u"ZOTERO_PREF_2"_ustr));
CPPUNIT_ASSERT(aMap.contains(u"OTHER"_ustr));
}
}
@@ -1047,7 +1047,7 @@ void OServiceManager::insert( const Any & Element )
// helper function
bool OServiceManager::haveFactoryWithThisImplementation(const OUString& aImplName)
{
return ( m_ImplementationNameMap.find(aImplName) != m_ImplementationNameMap.end());
return m_ImplementationNameMap.contains(aImplName);
}
// XSet
+1 -1
View File
@@ -208,7 +208,7 @@ const SlotIDToWhichIDMap& ItemInfoPackage::getSlotIDToWhichIDMap() const
if (0 != rCandidate.getSlotID())
{
#ifdef DBG_UTIL
if (maSlotIDToWhichIDMap.find(rCandidate.getSlotID()) != maSlotIDToWhichIDMap.end())
if (maSlotIDToWhichIDMap.contains(rCandidate.getSlotID()))
assert(false && "ITEM: SlotID used double in ItemInfoPackage (!)");
#endif
maSlotIDToWhichIDMap[rCandidate.getSlotID()] = rCandidate.getWhich();
+1 -1
View File
@@ -491,7 +491,7 @@ void SmartTagMgr::AssociateActionsWithRecognizers()
const OUString aSmartTagName = xRecognizer->getSmartTagName(j);
// check if smart tag type has already been processed:
if ( maSmartTagMap.find( aSmartTagName ) != maSmartTagMap.end() )
if ( maSmartTagMap.contains( aSmartTagName ) )
continue;
bool bFound = false;
+1 -1
View File
@@ -528,7 +528,7 @@ void CommentsPanel::deleteComment(sal_uInt32 nId)
// // If the root comment is deleted, the new root comment of the thread should be the next comment in the thread
// // but due to a bug `getRootCommentWin` returns root comment of some other/random thread so we completely lose
// // access to the current thread.
// if (mpThreadsMap.find(nId) != mpThreadsMap.end())
// if (mpThreadsMap.contains(nId))
// {
// pRootNote = mpThreadsMap[nId];
// }
+1 -1
View File
@@ -53,7 +53,7 @@ css::uno::Sequence< OUString > SAL_CALL CMimeContentType::getParameters( )
sal_Bool SAL_CALL CMimeContentType::hasParameter( const OUString& aName )
{
return ( m_ParameterMap.end( ) != m_ParameterMap.find( aName.toAsciiLowerCase() ) );
return m_ParameterMap.contains( aName.toAsciiLowerCase() );
}
OUString SAL_CALL CMimeContentType::getParameterValue( const OUString& aName )
+2 -2
View File
@@ -1673,7 +1673,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OUString
}
else if (name == "GtkIconView")
{
assert(rMap.find(u"model"_ustr) != rMap.end() && "GtkIconView must have a model");
assert(rMap.contains(u"model"_ustr) && "GtkIconView must have a model");
//window we want to apply the packing props for this GtkIconView to
VclPtr<vcl::Window> xWindowForPackingProps;
@@ -1696,7 +1696,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OUString
{
if (!isLegacy())
{
assert(rMap.find(u"model"_ustr) != rMap.end() && "GtkTreeView must have a model");
assert(rMap.contains(u"model"_ustr) && "GtkTreeView must have a model");
}
//window we want to apply the packing props for this GtkTreeView to
+1 -1
View File
@@ -507,7 +507,7 @@ void CPDManager::initialize()
std::unordered_map<OUString, Printer>::iterator it = m_aPrinters.begin();
while (it != m_aPrinters.end())
{
if (m_aCPDDestMap.find(it->first) != m_aCPDDestMap.end())
if (m_aCPDDestMap.contains(it->first))
{
++it;
continue;
+1 -1
View File
@@ -383,7 +383,7 @@ void CUPSManager::initialize()
std::unordered_map< OUString, Printer >::iterator it = m_aPrinters.begin();
while(it != m_aPrinters.end())
{
if( m_aCUPSDestMap.find( it->first ) != m_aCUPSDestMap.end() )
if( m_aCUPSDestMap.contains( it->first ) )
{
++it;
continue;
@@ -565,7 +565,7 @@ bool WPXSvInputStream::existsSubStream(const char* const name)
if (isOLE())
{
ensureOLEIsInitialized();
return mpOLEStorage->maNameMap.end() != mpOLEStorage->maNameMap.find(aName);
return mpOLEStorage->maNameMap.contains(aName);
}
mxSeekable->seek(0);
@@ -573,7 +573,7 @@ bool WPXSvInputStream::existsSubStream(const char* const name)
if (isZip())
{
ensureZipIsInitialized();
return mpZipStorage->maNameMap.end() != mpZipStorage->maNameMap.find(aName);
return mpZipStorage->maNameMap.contains(aName);
}
return false;