From 5ee0cf887301ea0e994e3ec7299f4958808fc2d8 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Tue, 20 Sep 2016 20:27:04 +0200 Subject: 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 Tested-by: Noel Grandin (cherry picked from commit 450a2fd5e2dafd1a0c08e73ef85db978f6b1a927) --- i18npool/inc/numberformatcode.hxx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'i18npool/inc/numberformatcode.hxx') 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 #include +#include +#include + 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(); }; -- cgit v1.2.3