diff options
author | Noel Grandin <noel@peralex.com> | 2021-05-01 08:30:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-02 10:00:43 +0200 |
commit | 86b345a963a64fd9b9a3cab522b3ac2e909977fd (patch) | |
tree | b55be7134aa02c203b0b4eea6afeab3aecfd65a6 /unotools/source/misc | |
parent | aa38eede9d340cbb11a792ab1ebbe681521a4489 (diff) |
tdf#79049 speed up OOXML workbook load (4)
Optimise LocaleDataWrapper for reads by initialising the
data we in the constructor, so we don't need any kind of
locking
Reduces load time from 34s to 28s.
Change-Id: I4bd3bddb30b70ba015fe5b1372534f9507762b74
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114960
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools/source/misc')
-rw-r--r-- | unotools/source/misc/syslocale.cxx | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx index 7f89d34f3946..d68522720834 100644 --- a/unotools/source/misc/syslocale.cxx +++ b/unotools/source/misc/syslocale.cxx @@ -57,13 +57,14 @@ public: virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override; private: - void setDateAcceptancePatternsConfig(); + std::vector<OUString> getDateAcceptancePatternsConfig(); }; SvtSysLocale_Impl::SvtSysLocale_Impl() { - pLocaleData.reset(new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() )); - setDateAcceptancePatternsConfig(); + pLocaleData.reset(new LocaleDataWrapper( + aSysLocaleOptions.GetRealLanguageTag(), + getDateAcceptancePatternsConfig() )); // listen for further changes aSysLocaleOptions.AddListener( this ); @@ -83,36 +84,33 @@ CharClass* SvtSysLocale_Impl::GetCharClass() void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints nHint ) { + if ( !(nHint & ConfigurationHints::Locale) && + !(nHint & ConfigurationHints::DatePatterns) ) + return; + MutexGuard aGuard( SvtSysLocale::GetMutex() ); + const LanguageTag& rLanguageTag = aSysLocaleOptions.GetRealLanguageTag(); if ( nHint & ConfigurationHints::Locale ) { - const LanguageTag& rLanguageTag = aSysLocaleOptions.GetRealLanguageTag(); - pLocaleData->setLanguageTag( rLanguageTag ); GetCharClass()->setLanguageTag( rLanguageTag ); } - if ( nHint & ConfigurationHints::DatePatterns ) - { - setDateAcceptancePatternsConfig(); - } + pLocaleData.reset(new LocaleDataWrapper(rLanguageTag, getDateAcceptancePatternsConfig())); } -void SvtSysLocale_Impl::setDateAcceptancePatternsConfig() +std::vector<OUString> SvtSysLocale_Impl::getDateAcceptancePatternsConfig() { OUString aStr( aSysLocaleOptions.GetDatePatternsConfigString()); if (aStr.isEmpty()) - pLocaleData->setDateAcceptancePatterns( uno::Sequence<OUString>()); // reset - else + return {}; // reset + ::std::vector< OUString > aVec; + for (sal_Int32 nIndex = 0; nIndex >= 0; /*nop*/) { - ::std::vector< OUString > aVec; - for (sal_Int32 nIndex = 0; nIndex >= 0; /*nop*/) - { - OUString aTok( aStr.getToken( 0, ';', nIndex)); - if (!aTok.isEmpty()) - aVec.push_back( aTok); - } - pLocaleData->setDateAcceptancePatterns( comphelper::containerToSequence(aVec) ); + OUString aTok( aStr.getToken( 0, ';', nIndex)); + if (!aTok.isEmpty()) + aVec.push_back( aTok); } + return aVec; } SvtSysLocale::SvtSysLocale() @@ -148,11 +146,6 @@ const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const return *(pImpl->pLocaleData); } -const LocaleDataWrapper* SvtSysLocale::GetLocaleDataPtr() const -{ - return pImpl->pLocaleData.get(); -} - const CharClass& SvtSysLocale::GetCharClass() const { return *(pImpl->GetCharClass()); |