summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-11-11 19:07:25 +0100
committerJulien Nabet <serval2412@yahoo.fr>2017-11-11 21:18:05 +0100
commitd092dd1b784fcf83fc9c63810bac24d4508edbbc (patch)
tree069926b3b811f5affdcf5af43ab2b64393e4b7e2
parent2b1f0d31c34464bdece4eea158097b3e4923cf5f (diff)
Replace list by vector in cellkeytranslator (sc)
Change-Id: I279f319bd3a3bf71cf0c7b138723d9601e693e7b Reviewed-on: https://gerrit.libreoffice.org/44634 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--sc/source/core/inc/cellkeytranslator.hxx4
-rw-r--r--sc/source/core/tool/cellkeytranslator.cxx30
2 files changed, 15 insertions, 19 deletions
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);