diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-23 08:49:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-23 18:35:00 +0200 |
commit | c66568d6b0bbcce26cbdc5a4e5f6e4c0ae748e45 (patch) | |
tree | 2237871caf9e1f78875e808ef81f565ba1aaf61f /i18npool | |
parent | 87f1f7fdb34fe452ac540524224e1e808ce5d3a2 (diff) |
loplugin:useuniqueptr, look for containers..
that can use std::unique_ptr, and apply it in i18npool
Change-Id: Ib410abaf73d5f392c7a7a9a322872b08c948f9e9
Reviewed-on: https://gerrit.libreoffice.org/41438
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/inc/breakiterator_unicode.hxx | 5 | ||||
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_unicode.cxx | 20 | ||||
-rw-r--r-- | i18npool/source/localedata/LocaleNode.cxx | 4 | ||||
-rw-r--r-- | i18npool/source/localedata/LocaleNode.hxx | 5 |
4 files changed, 13 insertions, 21 deletions
diff --git a/i18npool/inc/breakiterator_unicode.hxx b/i18npool/inc/breakiterator_unicode.hxx index 42dcb305777a..8783764cb0e1 100644 --- a/i18npool/inc/breakiterator_unicode.hxx +++ b/i18npool/inc/breakiterator_unicode.hxx @@ -22,6 +22,7 @@ #include <breakiteratorImpl.hxx> #include <unicode/brkiter.h> +#include <memory> namespace com { namespace sun { namespace star { namespace i18n { @@ -74,10 +75,10 @@ protected: { OUString aICUText; UText* ut; - icu::BreakIterator* aBreakIterator; + std::unique_ptr<icu::BreakIterator> aBreakIterator; css::lang::Locale maLocale; - BI_Data() : ut(nullptr), aBreakIterator(nullptr) + BI_Data() : ut(nullptr) { } ~BI_Data() diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx index 2256755e85be..cf781eb414a0 100644 --- a/i18npool/source/breakiterator/breakiterator_unicode.cxx +++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx @@ -49,11 +49,6 @@ BreakIterator_Unicode::BreakIterator_Unicode() BreakIterator_Unicode::~BreakIterator_Unicode() { - delete character.aBreakIterator; - delete sentence.aBreakIterator; - delete line.aBreakIterator; - for (BI_Data & word : words) - delete word.aBreakIterator; } /* @@ -107,10 +102,7 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Local rLocale.Language != icuBI->maLocale.Language || rLocale.Country != icuBI->maLocale.Country || rLocale.Variant != icuBI->maLocale.Variant) { - if (icuBI->aBreakIterator) { - delete icuBI->aBreakIterator; - icuBI->aBreakIterator=nullptr; - } + icuBI->aBreakIterator.reset(); if (rule) { uno::Sequence< OUString > breakRules = LocaleDataImpl::get()->getBreakIteratorRules(rLocale); @@ -160,7 +152,7 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Local case LOAD_LINE_BREAKITERATOR: rbi->publicSetBreakType(UBRK_LINE); break; } #endif - icuBI->aBreakIterator = rbi; + icuBI->aBreakIterator.reset( rbi ); } } @@ -170,16 +162,16 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Local status = U_ZERO_ERROR; switch (rBreakType) { case LOAD_CHARACTER_BREAKITERATOR: - icuBI->aBreakIterator = icu::BreakIterator::createCharacterInstance(icuLocale, status); + icuBI->aBreakIterator.reset( icu::BreakIterator::createCharacterInstance(icuLocale, status) ); break; case LOAD_WORD_BREAKITERATOR: - icuBI->aBreakIterator = icu::BreakIterator::createWordInstance(icuLocale, status); + icuBI->aBreakIterator.reset( icu::BreakIterator::createWordInstance(icuLocale, status) ); break; case LOAD_SENTENCE_BREAKITERATOR: - icuBI->aBreakIterator = icu::BreakIterator::createSentenceInstance(icuLocale, status); + icuBI->aBreakIterator.reset( icu::BreakIterator::createSentenceInstance(icuLocale, status) ); break; case LOAD_LINE_BREAKITERATOR: - icuBI->aBreakIterator = icu::BreakIterator::createLineInstance(icuLocale, status); + icuBI->aBreakIterator.reset( icu::BreakIterator::createLineInstance(icuLocale, status) ); break; } if ( !U_SUCCESS(status) ) { diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index a17ff49cefcf..5d3e29a3531c 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -73,7 +73,7 @@ void LocaleNode::printR () const { } void LocaleNode::addChild ( LocaleNode * node) { - children.push_back(node); + children.emplace_back(node); node->parent = this; } @@ -99,8 +99,6 @@ const LocaleNode * LocaleNode::findNode ( const sal_Char *name) const { LocaleNode::~LocaleNode() { - for (size_t i=0; i < children.size(); ++i) - delete children[i]; } LocaleNode* LocaleNode::createNode (const OUString& name, const Reference< XAttributeList > & attr) diff --git a/i18npool/source/localedata/LocaleNode.hxx b/i18npool/source/localedata/LocaleNode.hxx index c3e6c57e6a22..0f089d162bf3 100644 --- a/i18npool/source/localedata/LocaleNode.hxx +++ b/i18npool/source/localedata/LocaleNode.hxx @@ -23,6 +23,7 @@ #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> #include <vector> +#include <memory> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/xml/sax/SAXParseException.hpp> @@ -85,7 +86,7 @@ class LocaleNode OUString aValue; Attr aAttribs; LocaleNode * parent; - std::vector<LocaleNode*> children; + std::vector<std::unique_ptr<LocaleNode>> children; protected: mutable int nError; @@ -97,7 +98,7 @@ public: const OUString& getValue() const { return aValue; }; const Attr& getAttr() const { return aAttribs; }; sal_Int32 getNumberOfChildren () const { return sal_Int32(children.size()); }; - LocaleNode * getChildAt (sal_Int32 idx) const { return children[idx] ; }; + LocaleNode * getChildAt (sal_Int32 idx) const { return children[idx].get(); }; const LocaleNode * findNode ( const sal_Char *name) const; void print () const; void printR () const; |