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

Julien Nabet serval2412 at yahoo.fr
Sun Oct 1 18:07:57 UTC 2017


 filter/source/config/cache/cacheitem.hxx     |    3 +--
 filter/source/config/cache/typedetection.cxx |   16 +++++++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 0e3c3350cd7ef4b8d1b52fb6e5d8d17644cc4e61
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Oct 1 14:20:13 2017 +0200

    Replace list by vector in typedetection.cxx (filter)
    
    Change-Id: Idfb4c0e26a109157f95f3dfe2cfcdccbb2428502
    Reviewed-on: https://gerrit.libreoffice.org/42995
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/filter/source/config/cache/cacheitem.hxx b/filter/source/config/cache/cacheitem.hxx
index c598150556ec..e1b2dcd2a02f 100644
--- a/filter/source/config/cache/cacheitem.hxx
+++ b/filter/source/config/cache/cacheitem.hxx
@@ -21,7 +21,6 @@
 #define INCLUDED_FILTER_SOURCE_CONFIG_CACHE_CACHEITEM_HXX
 
 #include <deque>
-#include <list>
 #include <unordered_map>
 #include <com/sun/star/uno/Sequence.h>
 #include <com/sun/star/beans/PropertyValue.hpp>
@@ -194,7 +193,7 @@ struct FlatDetectionInfo
     FlatDetectionInfo();
 };
 
-typedef ::std::list< FlatDetectionInfo > FlatDetection;
+typedef ::std::vector< FlatDetectionInfo > FlatDetection;
 
     } // namespace config
 } // namespace filter
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index 9d5e5844c46f..d0c096ce28d8 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -318,7 +318,7 @@ struct SortByPriority
         // All things being equal, sort them alphabetically.
         return r1.sType > r2.sType;
     }
-};
+} objSortByPriority;
 
 struct SortByType
 
@@ -327,7 +327,7 @@ struct SortByType
     {
         return r1.sType > r2.sType;
     }
-};
+} objSortByType;
 
 struct EqualByType
 {
@@ -335,7 +335,7 @@ struct EqualByType
     {
         return r1.sType == r2.sType;
     }
-};
+} objEqualByType;
 
 class FindByType
 {
@@ -408,8 +408,9 @@ OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css::
         // <- SAFE ----------------------------------
 
         // Properly prioritize all candidate types.
-        lFlatTypes.sort(SortByPriority());
-        lFlatTypes.unique(EqualByType());
+        std::stable_sort(lFlatTypes.begin(), lFlatTypes.end(), objSortByPriority);
+        auto last = std::unique(lFlatTypes.begin(), lFlatTypes.end(), objEqualByType);
+        lFlatTypes.erase(last, lFlatTypes.end());
 
         OUString sLastChance;
 
@@ -854,8 +855,9 @@ void TypeDetection::impl_getAllFormatTypes(
     }
 
     // Remove duplicates.
-    rFlatTypes.sort(SortByType());
-    rFlatTypes.unique(EqualByType());
+    std::stable_sort(rFlatTypes.begin(), rFlatTypes.end(), objSortByType);
+    auto last = std::unique(rFlatTypes.begin(), rFlatTypes.end(), objEqualByType);
+    rFlatTypes.erase(last, rFlatTypes.end());
 
     // Mark pre-selected type (if any) to have it prioritized.
     OUString sSelectedType = rDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TYPENAME(), OUString());


More information about the Libreoffice-commits mailing list