diff options
author | Maarten Bosmans <mkbosmans@gmail.com> | 2016-09-20 20:27:04 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-10-10 21:13:15 +0200 |
commit | 5ee0cf887301ea0e994e3ec7299f4958808fc2d8 (patch) | |
tree | 038fc0685efe38df1d625f7328f79dfba9be8474 /i18npool/inc | |
parent | df53a5f695b37bdd3eef57203fc0a3f4c95dbeea (diff) |
tdf#53698: Cache more than 1 item in NumberFormatCodeMapper
In zforlist.cxx the function SvNumberFormatter::GetPreviewStringGuess
switches between the system locale and en_US in order to guess the
formatting of a number. This results in poor performance, because in
the created SvNumberFormat only the last used locale is cached.
Caching more than 1 entries improves the load time for the document
attached to tdf#53698 from 90s to 60s in case of non en_US locales.
Change-Id: Id0eb4447dea6213015e2d958d8303a1e7892487a
Reviewed-on: https://gerrit.libreoffice.org/29136
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 450a2fd5e2dafd1a0c08e73ef85db978f6b1a927)
Diffstat (limited to 'i18npool/inc')
-rw-r--r-- | i18npool/inc/numberformatcode.hxx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/i18npool/inc/numberformatcode.hxx b/i18npool/inc/numberformatcode.hxx index 9c7d78066d3e..48c64c24de70 100644 --- a/i18npool/inc/numberformatcode.hxx +++ b/i18npool/inc/numberformatcode.hxx @@ -29,6 +29,9 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <deque> +#include <utility> + class NumberFormatCodeMapper : public cppu::WeakImplHelper < css::i18n::XNumberFormatCode, @@ -55,19 +58,15 @@ public: private: osl::Mutex maMutex; - css::lang::Locale aLocale; - css::uno::Reference < css::uno::XComponentContext > mxContext; - css::uno::Sequence< css::i18n::FormatElement > aFormatSeq; - css::uno::Reference < css::i18n::XLocaleData4 > mxLocaleData; - bool bFormatsValid; + css::uno::Reference < css::i18n::XLocaleData4 > m_xLocaleData; + typedef std::pair< css::lang::Locale, css::uno::Sequence< css::i18n::FormatElement > > FormatElementCacheItem; + std::deque < FormatElementCacheItem > m_aFormatElementCache; - void setupLocale( const css::lang::Locale& rLocale ); - void getFormats( const css::lang::Locale& rLocale ); + const css::uno::Sequence< css::i18n::FormatElement >& getFormats( const css::lang::Locale& rLocale ); static OUString mapElementTypeShortToString(sal_Int16 formatType); static sal_Int16 mapElementTypeStringToShort(const OUString& formatType); static OUString mapElementUsageShortToString(sal_Int16 formatUsage); static sal_Int16 mapElementUsageStringToShort(const OUString& formatUsage); - void createLocaleDataObject(); }; |