[Libreoffice-commits] core.git: i18nutil/source include/i18nutil

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 31 06:31:37 UTC 2018


 i18nutil/source/utility/oneToOneMapping.cxx |   10 +---------
 include/i18nutil/oneToOneMapping.hxx        |    3 ++-
 2 files changed, 3 insertions(+), 10 deletions(-)

New commits:
commit 8003f8694ac7c4bc117f7ce692339534d37681f0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 29 14:25:42 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 31 07:31:11 2018 +0100

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

diff --git a/i18nutil/source/utility/oneToOneMapping.cxx b/i18nutil/source/utility/oneToOneMapping.cxx
index 8e71ea01e418..0fdea0599004 100644
--- a/i18nutil/source/utility/oneToOneMapping.cxx
+++ b/i18nutil/source/utility/oneToOneMapping.cxx
@@ -67,11 +67,6 @@ oneToOneMappingWithFlag::oneToOneMappingWithFlag( UnicodePairWithFlag const *rpT
 
 oneToOneMappingWithFlag::~oneToOneMappingWithFlag()
 {
-    if( mbHasIndex )
-    {
-        for (UnicodePairWithFlag const ** i : mpIndex)
-            delete [] i;
-    }
 }
 
 void oneToOneMappingWithFlag::makeIndex()
@@ -80,9 +75,6 @@ void oneToOneMappingWithFlag::makeIndex()
     {
         int current = -1;
 
-        for (UnicodePairWithFlag const **& i : mpIndex)
-            i = nullptr;
-
         for( size_t k = 0; k < mnSize; k++ )
         {
             const int high = (mpTableWF[k].first >> 8) & 0xFF;
@@ -90,7 +82,7 @@ void oneToOneMappingWithFlag::makeIndex()
             if( high != current )
             {
                 current = high;
-                mpIndex[high] = new UnicodePairWithFlag const *[256];
+                mpIndex[high].reset(new UnicodePairWithFlag const *[256]);
 
                 for (int j = 0; j < 256; ++j)
                     mpIndex[high][j] = nullptr;
diff --git a/include/i18nutil/oneToOneMapping.hxx b/include/i18nutil/oneToOneMapping.hxx
index c3e49f574f44..80550d957158 100644
--- a/include/i18nutil/oneToOneMapping.hxx
+++ b/include/i18nutil/oneToOneMapping.hxx
@@ -21,6 +21,7 @@
 
 #include <rtl/ustring.hxx>
 #include <i18nutil/i18nutildllapi.h>
+#include <memory>
 
 namespace i18nutil {
 
@@ -80,7 +81,7 @@ public:
 private:
     UnicodePairWithFlag const *mpTableWF;
     UnicodePairFlag       mnFlag;
-    UnicodePairWithFlag const **mpIndex[256];
+    std::unique_ptr<UnicodePairWithFlag const *[]> mpIndex[256];
     bool                  mbHasIndex;
 };
 


More information about the Libreoffice-commits mailing list