[Libreoffice-commits] core.git: xmlhelp/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 18 09:52:48 UTC 2018


 xmlhelp/source/cxxhelp/provider/databases.cxx |   41 ++++++++++----------------
 xmlhelp/source/cxxhelp/provider/databases.hxx |    6 +--
 2 files changed, 19 insertions(+), 28 deletions(-)

New commits:
commit 70c0c3b6157a869074ad7e9909b0e48d2da245e0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Sep 17 09:18:28 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Sep 18 11:52:24 2018 +0200

    loplugin:useuniqueptr in xmlhelp::Databases
    
    Change-Id: Idaf73fd5d12badbee58861c6ca3b087c16946b9c
    Reviewed-on: https://gerrit.libreoffice.org/60615
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 2ab99629f3df..d71c62b4a95c 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -165,23 +165,14 @@ Databases::~Databases()
 {
     // unload the databases
 
-    {
-        // DatabasesTable
-        for (auto& rDatabase : m_aDatabases)
-            delete rDatabase.second;
-    }
+    // DatabasesTable
+    m_aDatabases.clear();
 
-    {
-        //  ModInfoTable
-        for (auto& rModInfo : m_aModInfo)
-            delete rModInfo.second;
-    }
+    //  ModInfoTable
+    m_aModInfo.clear();
 
-    {
-        // KeywordInfoTable
-        for (auto& rKeywordInfo : m_aKeywordInfo)
-            delete rKeywordInfo.second;
-    }
+    // KeywordInfoTable
+    m_aKeywordInfo.clear();
 }
 
 OString Databases::getImageTheme()
@@ -390,14 +381,14 @@ StaticModuleInformation* Databases::getStaticInformationForModule( const OUStrin
                     lineBuffer[ pos++ ] = ch;
             }
             replaceName( title );
-            it->second = new StaticModuleInformation( title,
+            it->second.reset(new StaticModuleInformation( title,
                                                       startid,
                                                       program,
-                                                      order );
+                                                      order ));
         }
     }
 
-    return it->second;
+    return it->second.get();
 }
 
 OUString Databases::processLang( const OUString& Language )
@@ -460,13 +451,13 @@ helpdatafileproxy::Hdf* Databases::getHelpDataFile( const OUString& Database,
         key = *pExtensionPath + Language + dbFileName;      // make unique, don't change language
 
     std::pair< DatabasesTable::iterator,bool > aPair =
-        m_aDatabases.emplace( key, reinterpret_cast<helpdatafileproxy::Hdf *>(0) );
+        m_aDatabases.emplace( key, nullptr);
 
     DatabasesTable::iterator it = aPair.first;
 
     if( aPair.second && ! it->second )
     {
-        helpdatafileproxy::Hdf* pHdf = nullptr;
+        std::unique_ptr<helpdatafileproxy::Hdf> pHdf;
 
         OUString fileURL;
         if( pExtensionPath )
@@ -482,13 +473,13 @@ helpdatafileproxy::Hdf* Databases::getHelpDataFile( const OUString& Database,
         //fails for example when using long path names on Windows (starting with \\?\)
         if( m_xSFA->exists( fileNameHDFHelp ) )
         {
-            pHdf = new helpdatafileproxy::Hdf( fileNameHDFHelp, m_xSFA );
+            pHdf.reset(new helpdatafileproxy::Hdf( fileNameHDFHelp, m_xSFA ));
         }
 
-        it->second = pHdf;
+        it->second = std::move(pHdf);
     }
 
-    return it->second;
+    return it->second.get();
 }
 
 Reference< XCollator >
@@ -775,10 +766,10 @@ KeywordInfo* Databases::getKeyword( const OUString& Database,
         KeywordElementComparator aComparator( xCollator );
         std::sort(aVector.begin(),aVector.end(),aComparator);
 
-        it->second = new KeywordInfo( aVector );
+        it->second.reset(new KeywordInfo( aVector ));
     }
 
-    return it->second;
+    return it->second.get();
 }
 
 Reference< XHierarchicalNameAccess > Databases::jarFile( const OUString& jar,
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx
index ae3e5049af5c..3900e9918cdc 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -257,16 +257,16 @@ namespace chelp {
 
         std::vector< OUString >    m_avModules;
 
-        typedef std::unordered_map< OUString,helpdatafileproxy::Hdf* >   DatabasesTable;
+        typedef std::unordered_map< OUString, std::unique_ptr<helpdatafileproxy::Hdf> >   DatabasesTable;
         DatabasesTable m_aDatabases;         // Language and module dependent databases
 
         typedef std::unordered_map< OUString,OUString > LangSetTable;
         LangSetTable m_aLangSet;   // Mapping to of lang-country to lang
 
-        typedef std::unordered_map< OUString,StaticModuleInformation* > ModInfoTable;
+        typedef std::unordered_map< OUString, std::unique_ptr<StaticModuleInformation> > ModInfoTable;
         ModInfoTable m_aModInfo;   // Module information
 
-        typedef std::unordered_map< OUString,KeywordInfo* > KeywordInfoTable;
+        typedef std::unordered_map< OUString, std::unique_ptr<KeywordInfo> > KeywordInfoTable;
         KeywordInfoTable m_aKeywordInfo;   // Module information
 
         typedef


More information about the Libreoffice-commits mailing list