diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-10 20:53:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-11 10:54:22 +0200 |
commit | 5ef182586ae2019fa6f6a59dae1b41b2225665bf (patch) | |
tree | f531a471ddec271e9bb5694d917e034cb7d86770 /i18npool/source | |
parent | da40449dc5f1841ac3e6f6aa1194834a363455b6 (diff) |
no need to allocate the lookupTableItem separately
Change-Id: I43919a002df01c6329ee483bf69f04669cdce1f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120293
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool/source')
3 files changed, 18 insertions, 21 deletions
diff --git a/i18npool/source/characterclassification/characterclassificationImpl.cxx b/i18npool/source/characterclassification/characterclassificationImpl.cxx index 721c82bf9304..8146612a87fc 100644 --- a/i18npool/source/characterclassification/characterclassificationImpl.cxx +++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx @@ -125,10 +125,10 @@ bool CharacterClassificationImpl::createLocaleSpecificCharacterClassification(co { // to share service between same Language but different Country code, like zh_CN and zh_SG for (size_t l = 0; l < lookupTable.size(); l++) { - cachedItem = lookupTable[l].get(); + cachedItem = lookupTable[l]; if (serviceName == cachedItem->aName) { - lookupTable.emplace_back( new lookupTableItem(rLocale, serviceName, cachedItem->xCI) ); - cachedItem = lookupTable.back().get(); + lookupTable.emplace_back( rLocale, serviceName, cachedItem->xCI ); + cachedItem = lookupTable.back(); return true; } } @@ -140,8 +140,8 @@ bool CharacterClassificationImpl::createLocaleSpecificCharacterClassification(co if ( xI.is() ) { xCI.set( xI, UNO_QUERY ); if (xCI.is()) { - lookupTable.emplace_back( new lookupTableItem(rLocale, serviceName, xCI) ); - cachedItem = lookupTable.back().get(); + lookupTable.emplace_back( rLocale, serviceName, xCI ); + cachedItem = lookupTable.back(); return true; } } @@ -156,7 +156,7 @@ CharacterClassificationImpl::getLocaleSpecificCharacterClassification(const Loca return cachedItem->xCI; else { for (const auto & i : lookupTable) { - cachedItem = i.get(); + cachedItem = i; if (cachedItem->equals(rLocale)) return cachedItem->xCI; } @@ -179,8 +179,8 @@ CharacterClassificationImpl::getLocaleSpecificCharacterClassification(const Loca return cachedItem->xCI; else if (xUCI.is()) { - lookupTable.emplace_back( new lookupTableItem(rLocale, "Unicode", xUCI) ); - cachedItem = lookupTable.back().get(); + lookupTable.emplace_back( rLocale, "Unicode", xUCI ); + cachedItem = lookupTable.back(); return cachedItem->xCI; } } diff --git a/i18npool/source/collator/collatorImpl.cxx b/i18npool/source/collator/collatorImpl.cxx index 3253b458159f..56fb4bf90502 100644 --- a/i18npool/source/collator/collatorImpl.cxx +++ b/i18npool/source/collator/collatorImpl.cxx @@ -34,7 +34,6 @@ namespace i18npool { CollatorImpl::CollatorImpl( const Reference < XComponentContext >& rxContext ) : m_xContext(rxContext) { mxLocaleData.set( LocaleData2::create(rxContext) ); - cachedItem = nullptr; } CollatorImpl::~CollatorImpl() @@ -139,10 +138,10 @@ bool CollatorImpl::createCollator(const lang::Locale& rLocale, const OUString& serviceName, const OUString& rSortAlgorithm) { for (size_t l = 0; l < lookupTable.size(); l++) { - cachedItem = lookupTable[l].get(); + cachedItem = lookupTable[l]; if (cachedItem->service == serviceName) {// cross locale sharing - lookupTable.emplace_back(new lookupTableItem(rLocale, rSortAlgorithm, serviceName, cachedItem->xC)); - cachedItem = lookupTable.back().get(); + lookupTable.emplace_back(rLocale, rSortAlgorithm, serviceName, cachedItem->xC); + cachedItem = lookupTable.back(); return true; } } @@ -153,8 +152,8 @@ CollatorImpl::createCollator(const lang::Locale& rLocale, const OUString& servic Reference < XCollator > xC; xC.set( xI, UNO_QUERY ); if (xC.is()) { - lookupTable.emplace_back(new lookupTableItem(rLocale, rSortAlgorithm, serviceName, xC)); - cachedItem = lookupTable.back().get(); + lookupTable.emplace_back(rLocale, rSortAlgorithm, serviceName, xC); + cachedItem = lookupTable.back(); return true; } } @@ -165,7 +164,7 @@ void CollatorImpl::loadCachedCollator(const lang::Locale& rLocale, const OUString& rSortAlgorithm) { for (const auto& i : lookupTable) { - cachedItem = i.get(); + cachedItem = i; if (cachedItem->equals(rLocale, rSortAlgorithm)) { return; } @@ -200,7 +199,7 @@ CollatorImpl::loadCachedCollator(const lang::Locale& rLocale, const OUString& rS bLoaded = createCollator( rLocale, "Unicode", rSortAlgorithm); if (!bLoaded) { - cachedItem = nullptr; + cachedItem.reset(); throw RuntimeException(); // could not load any service } } diff --git a/i18npool/source/inputchecker/inputsequencechecker.cxx b/i18npool/source/inputchecker/inputsequencechecker.cxx index f27ed5c9e266..4820c10ca153 100644 --- a/i18npool/source/inputchecker/inputsequencechecker.cxx +++ b/i18npool/source/inputchecker/inputsequencechecker.cxx @@ -32,12 +32,10 @@ namespace i18npool { InputSequenceCheckerImpl::InputSequenceCheckerImpl( const Reference < XComponentContext >& rxContext ) : m_xContext( rxContext ) { serviceName = "com.sun.star.i18n.InputSequenceChecker"; - cachedItem = nullptr; } InputSequenceCheckerImpl::InputSequenceCheckerImpl(const char *pServiceName) : serviceName(pServiceName) - , cachedItem(nullptr) { } @@ -109,7 +107,7 @@ InputSequenceCheckerImpl::getInputSequenceChecker(char const * rLanguage) } else { for (const auto& l : lookupTable) { - cachedItem = l.get(); + cachedItem = l; if (cachedItem->aLanguage == rLanguage) return cachedItem->xISC; } @@ -122,8 +120,8 @@ InputSequenceCheckerImpl::getInputSequenceChecker(char const * rLanguage) if ( xI.is() ) { Reference< XExtendedInputSequenceChecker > xISC( xI, UNO_QUERY ); if (xISC.is()) { - lookupTable.emplace_back(new lookupTableItem(rLanguage, xISC)); - cachedItem = lookupTable.back().get(); + lookupTable.emplace_back(rLanguage, xISC); + cachedItem = lookupTable.back(); return cachedItem->xISC; } } |