[Libreoffice-commits] core.git: basic/source sc/source sd/source toolkit/source

Takeshi Abe tabe at fixedpoint.jp
Sat Jun 24 17:41:25 UTC 2017


 basic/source/uno/scriptcont.cxx                                 |    5 +----
 sc/source/filter/excel/excimp8.cxx                              |    3 +--
 sd/source/ui/framework/configuration/ResourceFactoryManager.cxx |    2 +-
 toolkit/source/controls/dialogcontrol.cxx                       |    3 +--
 4 files changed, 4 insertions(+), 9 deletions(-)

New commits:
commit 6ade3ef203238a211754c9c69000f155edd15ca9
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Fri Jun 23 18:00:07 2017 +0900

    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 at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

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
     {


More information about the Libreoffice-commits mailing list