summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-06-23 18:00:07 +0900
committerJulien Nabet <serval2412@yahoo.fr>2017-06-24 19:41:04 +0200
commit6ade3ef203238a211754c9c69000f155edd15ca9 (patch)
tree64471b9cda039b028fcd283b9055f83062a1e0a7
parent879fea59a0bcc1a439e51ab0923e1cc41dff5bfb (diff)
std::unordered_map can erase an element by given key, if any
so that it is unneeded to find its position in advance. Change-Id: Iccf92f98b8683e4b2fb5252f5e05a357268b7033 Reviewed-on: https://gerrit.libreoffice.org/39156 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--basic/source/uno/scriptcont.cxx5
-rw-r--r--sc/source/filter/excel/excimp8.cxx3
-rw-r--r--sd/source/ui/framework/configuration/ResourceFactoryManager.cxx2
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx3
4 files changed, 4 insertions, 9 deletions
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 4346a091ff01..44ee7c787244 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -1241,11 +1241,8 @@ void SAL_CALL SfxScriptLibrary::insertModuleInfo( const OUString& ModuleName, co
void SAL_CALL SfxScriptLibrary::removeModuleInfo( const OUString& ModuleName )
{
// #FIXME add NoSuchElementException to the spec
- if ( !hasModuleInfo( ModuleName ) )
- {
+ if ( mModuleInfo.erase( ModuleName ) == 0 )
throw NoSuchElementException();
- }
- mModuleInfo.erase( mModuleInfo.find( ModuleName ) );
}
} // namespace basic
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 2b7326be0ef3..849fee3b4157 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -156,9 +156,8 @@ public:
virtual void SAL_CALL removeByName( const OUString& aName ) override
{
::osl::MutexGuard aGuard( m_aMutex );
- if ( !hasByName( aName ) )
+ if ( IdToOleNameHash.erase( aName ) == 0 )
throw container::NoSuchElementException();
- IdToOleNameHash.erase( IdToOleNameHash.find( aName ) );
}
virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) override
{
diff --git a/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx b/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx
index 6b7d73cc4d65..22133635c731 100644
--- a/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx
+++ b/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx
@@ -141,7 +141,7 @@ void ResourceFactoryManager::RemoveFactoryForReference(
// Remove the entries whose keys we just have collected.
::std::vector<OUString>::const_iterator iKey;
for (iKey=aKeys.begin(); iKey!=aKeys.end(); ++iKey)
- maFactoryMap.erase(maFactoryMap.find(*iKey));
+ maFactoryMap.erase(*iKey);
// Remove the pattern entries whose factories are identical to the given
// factory.
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index 06ce235374c1..48a8664ed9be 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -120,9 +120,8 @@ public:
virtual void SAL_CALL removeByName( const OUString& aName ) override
{
::osl::MutexGuard aGuard( m_aMutex );
- if ( !hasByName( aName ) )
+ if ( things.erase( aName ) == 0 )
throw NoSuchElementException();
- things.erase( things.find( aName ) );
}
virtual Type SAL_CALL getElementType( ) override
{