[Libreoffice-commits] core.git: i18npool/inc i18npool/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 28 12:05:12 UTC 2019
i18npool/inc/defaultnumberingprovider.hxx | 4 +++
i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx | 12 ++++++++++
2 files changed, 16 insertions(+)
New commits:
commit b0b1dbfb1d6b28339c2cdd79b765ec3eb5ce5aaf
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jun 26 15:31:06 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jun 28 14:04:30 2019 +0200
tdf#125706 Fields slow down down load, part3
Cache the supported numbering types in DefaultNumberingProvider.
Takes the load time from 4.5s to 3.9s
Change-Id: I6495f37faec7dba60ff30bd13e90790e70f8e704
Reviewed-on: https://gerrit.libreoffice.org/74742
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/i18npool/inc/defaultnumberingprovider.hxx b/i18npool/inc/defaultnumberingprovider.hxx
index f01378ab075e..eb309b83c358 100644
--- a/i18npool/inc/defaultnumberingprovider.hxx
+++ b/i18npool/inc/defaultnumberingprovider.hxx
@@ -25,12 +25,14 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
+#include <map>
namespace com::sun::star::container { class XHierarchicalNameAccess; }
namespace com::sun::star::uno { class XComponentContext; }
namespace i18npool {
class TransliterationImpl;
class NativeNumberSupplierService;
+ struct Supported_NumberingType;
}
namespace i18npool {
@@ -78,6 +80,8 @@ private:
css::uno::Reference < css::container::XHierarchicalNameAccess > xHierarchicalNameAccess;
rtl::Reference<TransliterationImpl> translit;
rtl::Reference<NativeNumberSupplierService> mxNatNum;
+ std::map<OUString, const Supported_NumberingType*> maSupportedTypesCache;
+
/// @throws css::uno::RuntimeException
OUString makeNumberingIdentifier( sal_Int16 index );
/// @throws css::uno::RuntimeException
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 5e21a5a4dc5d..6f45022486a0 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -1072,17 +1072,29 @@ Sequence< sal_Int16 > DefaultNumberingProvider::getSupportedNumberingTypes( )
sal_Int16 DefaultNumberingProvider::getNumberingType( const OUString& rNumberingIdentifier )
{
+ auto it = maSupportedTypesCache.find(rNumberingIdentifier);
+ if (it != maSupportedTypesCache.end())
+ return it->second->nType;
for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
if(rNumberingIdentifier == makeNumberingIdentifier(i))
+ {
+ maSupportedTypesCache.emplace(rNumberingIdentifier, &aSupportedTypes[i]);
return aSupportedTypes[i].nType;
+ }
throw RuntimeException();
}
sal_Bool DefaultNumberingProvider::hasNumberingType( const OUString& rNumberingIdentifier )
{
+ auto it = maSupportedTypesCache.find(rNumberingIdentifier);
+ if (it != maSupportedTypesCache.end())
+ return true;
for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
if(rNumberingIdentifier == makeNumberingIdentifier(i))
+ {
+ maSupportedTypesCache.emplace(rNumberingIdentifier, &aSupportedTypes[i]);
return true;
+ }
return false;
}
More information about the Libreoffice-commits
mailing list