summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-26 11:47:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-27 09:54:44 +0200
commitc91f8e55fa9a335a4cc10f70e95e8a60a658c13b (patch)
tree22ef91f2df3a1f8c6ddf4059fa19c39d2aa0bc94 /l10ntools
parent0f87f895380833084b64145c686f0ba5993737ca (diff)
loplugin:useuniqueptr in MergeDataHashMap
Change-Id: I263c187bab997b6ab929ca04788214d7418cb449 Reviewed-on: https://gerrit.libreoffice.org/51928 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/export.hxx4
-rw-r--r--l10ntools/source/merge.cxx12
2 files changed, 7 insertions, 9 deletions
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index 0ed0f45c5175..5a9389ff7d19 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -151,7 +151,7 @@ class MergeData;
class MergeDataHashMap
{
private:
- typedef std::unordered_map<OString, MergeData*> HashMap_t;
+ typedef std::unordered_map<OString, std::unique_ptr<MergeData>> HashMap_t;
public:
MergeDataHashMap()
@@ -165,7 +165,7 @@ class MergeDataHashMap
typedef HashMap_t::iterator iterator;
typedef HashMap_t::const_iterator const_iterator;
- std::pair<iterator,bool> insert(const OString& rKey, MergeData* pMergeData);
+ std::pair<iterator,bool> insert(const OString& rKey, std::unique_ptr<MergeData> pMergeData);
iterator const & find(const OString& rKey);
iterator begin() {return m_aHashMap.begin();}
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 66aca214467d..4e55b45a6942 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -111,9 +111,9 @@ OString MergeEntrys::GetQTZText(const ResData& rResData, const OString& rOrigTex
// class MergeDataHashMap
-std::pair<MergeDataHashMap::iterator,bool> MergeDataHashMap::insert(const OString& rKey, MergeData* pMergeData)
+std::pair<MergeDataHashMap::iterator,bool> MergeDataHashMap::insert(const OString& rKey, std::unique_ptr<MergeData> pMergeData)
{
- std::pair<iterator,bool> aTemp = m_aHashMap.emplace( rKey, pMergeData );
+ std::pair<iterator,bool> aTemp = m_aHashMap.emplace( rKey, std::move(pMergeData) );
if( m_aHashMap.size() == 1 )
{
// When first insert, set an iterator to the first element
@@ -296,8 +296,6 @@ MergeDataFile::MergeDataFile(
MergeDataFile::~MergeDataFile()
{
- for (auto const& elem : aMap)
- delete elem.second;
}
std::vector<OString> MergeDataFile::GetLanguages() const
@@ -325,7 +323,7 @@ MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive
{
pResData->sGId = sOldG;
pResData->sId = sOldL;
- return mit->second;
+ return mit->second.get();
}
pResData->sGId = sOldG;
pResData->sId = sOldL;
@@ -366,14 +364,14 @@ void MergeDataFile::InsertEntry(
{
MergeDataHashMap::const_iterator mit = aMap.find( sKey );
if(mit != aMap.end())
- pData = mit->second;
+ pData = mit->second.get();
}
if( !pData )
{
pData = new MergeData;
- aMap.insert( sKey, pData );
+ aMap.insert( sKey, std::unique_ptr<MergeData>(pData) );
}