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

Julien Nabet serval2412 at yahoo.fr
Sat Nov 11 20:18:39 UTC 2017


 sc/source/core/inc/cellkeytranslator.hxx  |    4 ++--
 sc/source/core/tool/cellkeytranslator.cxx |   30 +++++++++++++-----------------
 2 files changed, 15 insertions(+), 19 deletions(-)

New commits:
commit d092dd1b784fcf83fc9c63810bac24d4508edbbc
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sat Nov 11 19:07:25 2017 +0100

    Replace list by vector in cellkeytranslator (sc)
    
    Change-Id: I279f319bd3a3bf71cf0c7b138723d9601e693e7b
    Reviewed-on: https://gerrit.libreoffice.org/44634
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/sc/source/core/inc/cellkeytranslator.hxx b/sc/source/core/inc/cellkeytranslator.hxx
index 766a0689a071..892d65d6f6c9 100644
--- a/sc/source/core/inc/cellkeytranslator.hxx
+++ b/sc/source/core/inc/cellkeytranslator.hxx
@@ -23,7 +23,7 @@
 #include <global.hxx>
 #include <formula/opcode.hxx>
 #include <unotools/transliterationwrapper.hxx>
-#include <list>
+#include <vector>
 #include <memory>
 #include <unordered_map>
 
@@ -40,7 +40,7 @@ struct ScCellKeyword
     ScCellKeyword(const sal_Char* pName, OpCode eOpCode, const css::lang::Locale& rLocale);
 };
 
-typedef std::unordered_map< OUString, ::std::list<ScCellKeyword> > ScCellKeywordHashMap;
+typedef std::unordered_map< OUString, ::std::vector<ScCellKeyword> > ScCellKeywordHashMap;
 
 /** Translate cell function keywords.
 
diff --git a/sc/source/core/tool/cellkeytranslator.cxx b/sc/source/core/tool/cellkeytranslator.cxx
index effc7145970e..c34276ce76a9 100644
--- a/sc/source/core/tool/cellkeytranslator.cxx
+++ b/sc/source/core/tool/cellkeytranslator.cxx
@@ -27,7 +27,6 @@
 #include <unotools/syslocale.hxx>
 
 using ::com::sun::star::uno::Sequence;
-using ::std::list;
 
 using namespace ::com::sun::star;
 
@@ -98,57 +97,55 @@ static void lclMatchKeyword(OUString& rName, const ScCellKeywordHashMap& aMap,
     LocaleMatch eLocaleMatchLevel = LOCALE_MATCH_NONE;
     bool bOpCodeMatched = false;
 
-    list<ScCellKeyword>::const_iterator itrListEnd = itr->second.end();
-    list<ScCellKeyword>::const_iterator itrList = itr->second.begin();
-    for ( ; itrList != itrListEnd; ++itrList )
+    for (auto const& elem : itr->second)
     {
         if ( eOpCode != ocNone && pLocale )
         {
-            if ( itrList->meOpCode == eOpCode )
+            if (elem.meOpCode == eOpCode)
             {
-                LocaleMatch eLevel = lclLocaleCompare(itrList->mrLocale, aLanguageTag);
+                LocaleMatch eLevel = lclLocaleCompare(elem.mrLocale, aLanguageTag);
                 if ( eLevel == LOCALE_MATCH_ALL )
                 {
                     // Name with matching opcode and locale found.
-                    rName = OUString::createFromAscii( itrList->mpName );
+                    rName = OUString::createFromAscii( elem.mpName );
                     return;
                 }
                 else if ( eLevel > eLocaleMatchLevel )
                 {
                     // Name with a better matching locale.
                     eLocaleMatchLevel = eLevel;
-                    aBestMatchName = itrList->mpName;
+                    aBestMatchName = elem.mpName;
                 }
                 else if ( !bOpCodeMatched )
                     // At least the opcode matches.
-                    aBestMatchName = itrList->mpName;
+                    aBestMatchName = elem.mpName;
 
                 bOpCodeMatched = true;
             }
         }
         else if ( eOpCode != ocNone && !pLocale )
         {
-            if ( itrList->meOpCode == eOpCode )
+            if ( elem.meOpCode == eOpCode )
             {
                 // Name with a matching opcode preferred.
-                rName = OUString::createFromAscii( itrList->mpName );
+                rName = OUString::createFromAscii( elem.mpName );
                 return;
             }
         }
         else if ( pLocale )
         {
-            LocaleMatch eLevel = lclLocaleCompare(itrList->mrLocale, aLanguageTag);
+            LocaleMatch eLevel = lclLocaleCompare(elem.mrLocale, aLanguageTag);
             if ( eLevel == LOCALE_MATCH_ALL )
             {
                 // Name with matching locale preferred.
-                rName = OUString::createFromAscii( itrList->mpName );
+                rName = OUString::createFromAscii( elem.mpName );
                 return;
             }
             else if ( eLevel > eLocaleMatchLevel )
             {
                 // Name with a better matching locale.
                 eLocaleMatchLevel = eLevel;
-                aBestMatchName = itrList->mpName;
+                aBestMatchName = elem.mpName;
             }
         }
     }
@@ -214,9 +211,8 @@ void ScCellKeywordTranslator::addToMap(const OUString& rKey, const sal_Char* pNa
     if ( itr == itrEnd )
     {
         // New keyword.
-        list<ScCellKeyword> aList;
-        aList.push_back(aKeyItem);
-        maStringNameMap.emplace(rKey, aList);
+        std::vector<ScCellKeyword> aVector { aKeyItem };
+        maStringNameMap.emplace(rKey, aVector);
     }
     else
         itr->second.push_back(aKeyItem);


More information about the Libreoffice-commits mailing list