linguistic/source/spelldsp.cxx |   13 +++++--------
 linguistic/source/spelldsp.hxx |    6 +++---
 2 files changed, 8 insertions(+), 11 deletions(-)

New commits:
commit 97b5bf4a39f33a3e51f1aa72339a5e88d1b9e9f3
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Tue Jan 23 16:48:17 2018 +0200

    loplugin:useuniqueptr in SpellCheckerDispatcher
    
    the call to ClearSvcList() was also unnecessary, the map will get
    cleared by the destructor anyway
    
    Change-Id: I24a077143c0cd57b0cfef721169c62f5b283b9c9
    Reviewed-on: https://gerrit.libreoffice.org/48739
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index 49009b70c3d5..6cd6c8003233 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -185,9 +185,6 @@ SpellCheckerDispatcher::SpellCheckerDispatcher( LngSvcMgr 
&rLngSvcMgr ) :
 
 SpellCheckerDispatcher::~SpellCheckerDispatcher()
 {
-    ClearSvcList();
-    delete m_pCache;
-    delete m_pCharClass;
 }
 
 
@@ -422,9 +419,9 @@ bool SpellCheckerDispatcher::isValid_Impl(
                 bRes = !xTmp->isNegative();
             } else {
                 setCharClass(LanguageTag(nLanguage));
-                CapType ct = capitalType(aChkWord, m_pCharClass);
+                CapType ct = capitalType(aChkWord, m_pCharClass.get());
                 if (ct == CapType::INITCAP || ct == CapType::ALLCAP) {
-                    Reference< XDictionaryEntry > xTmp2( 
lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass), nLanguage 
) );
+                    Reference< XDictionaryEntry > xTmp2( 
lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass.get()), 
nLanguage ) );
                     if (xTmp2.is()) {
                         bRes = !xTmp2->isNegative();
                     }
@@ -663,10 +660,10 @@ Reference< XSpellAlternatives > 
SpellCheckerDispatcher::spell_Impl(
             else
             {
                 setCharClass(LanguageTag(nLanguage));
-                CapType ct = capitalType(aChkWord, m_pCharClass);
+                CapType ct = capitalType(aChkWord, m_pCharClass.get());
                 if (ct == CapType::INITCAP || ct == CapType::ALLCAP)
                 {
-                    Reference< XDictionaryEntry > xTmp2( 
lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass), nLanguage 
) );
+                    Reference< XDictionaryEntry > xTmp2( 
lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass.get()), 
nLanguage ) );
                     if (xTmp2.is())
                     {
                         if (xTmp2->isNegative())    // negative entry found
@@ -842,7 +839,7 @@ void SpellCheckerDispatcher::FlushSpellCache()
 void SpellCheckerDispatcher::setCharClass(const LanguageTag& rLanguageTag)
 {
     if (!m_pCharClass)
-        m_pCharClass = new CharClass(rLanguageTag);
+        m_pCharClass.reset( new CharClass(rLanguageTag) );
     m_pCharClass->setLanguageTag(rLanguageTag);
 }
 
diff --git a/linguistic/source/spelldsp.hxx b/linguistic/source/spelldsp.hxx
index 9d165dd87347..d84d11a4513a 100644
--- a/linguistic/source/spelldsp.hxx
+++ b/linguistic/source/spelldsp.hxx
@@ -58,8 +58,8 @@ class SpellCheckerDispatcher :
     css::uno::Reference< css::linguistic2::XSearchableDictionaryList >  
m_xDicList;
 
     LngSvcMgr                       &m_rMgr;
-    mutable linguistic::SpellCache  *m_pCache; // Spell Cache (holds known 
words)
-    CharClass                       *m_pCharClass;
+    mutable std::unique_ptr<linguistic::SpellCache> m_pCache; // Spell Cache 
(holds known words)
+    std::unique_ptr<CharClass>       m_pCharClass;
 
     SpellCheckerDispatcher(const SpellCheckerDispatcher &) = delete;
     SpellCheckerDispatcher & operator = (const SpellCheckerDispatcher &) = 
delete;
@@ -120,7 +120,7 @@ private:
 inline linguistic::SpellCache & SpellCheckerDispatcher::GetCache() const
 {
     if (!m_pCache)
-        m_pCache = new linguistic::SpellCache();
+        m_pCache.reset(new linguistic::SpellCache());
     return *m_pCache;
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to