From 787525a314de9c8178d0fedcd71ddbd08ec41a55 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 16 May 2019 13:10:44 +0200 Subject: tdf#125254 Performance: A spreadsheet opens too slow, NameSpaceEntry NameSpaceEntry does not need to be a weak object, it is sufficient to be ref-counted. The empty string in SvXMLNamespaceMap can be statically allocated. Don't allocate a NameSpaceEntry in GetKeyByAttrName_ if we don't intend to cache it. Takes the load time from 39.5s to 38.5s. Change-Id: I4a9a1296af84c12d44e9b3ff354297f37d29f1e8 Reviewed-on: https://gerrit.libreoffice.org/72515 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/xmloff/nmspmap.hxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include/xmloff/nmspmap.hxx') diff --git a/include/xmloff/nmspmap.hxx b/include/xmloff/nmspmap.hxx index 1eb0f8f15b95..9c4c57393200 100644 --- a/include/xmloff/nmspmap.hxx +++ b/include/xmloff/nmspmap.hxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include @@ -39,7 +39,7 @@ const sal_uInt16 XML_NAMESPACE_NONE = USHRT_MAX-1; const sal_uInt16 XML_NAMESPACE_UNKNOWN = USHRT_MAX; const sal_uInt16 XML_NAMESPACE_UNKNOWN_FLAG = 0x8000; -class NameSpaceEntry : public cppu::OWeakObject +class NameSpaceEntry : public salhelper::SimpleReferenceObject { public: // sName refers to the full namespace name @@ -47,7 +47,7 @@ public: // sPrefix is the prefix used to declare a given item to be from a given namespace OUString sPrefix; // nKey is the unique identifier of a namespace - sal_uInt16 nKey; + sal_uInt16 nKey; }; typedef ::std::pair < sal_uInt16, OUString > QNamePair; @@ -65,12 +65,11 @@ struct QNamePairHash typedef std::unordered_map < QNamePair, OUString, QNamePairHash > QNameCache; typedef std::unordered_map < OUString, ::rtl::Reference > NameSpaceHash; -typedef std::map < sal_uInt16, ::rtl::Reference < NameSpaceEntry > > NameSpaceMap; +typedef std::unordered_map < sal_uInt16, ::rtl::Reference < NameSpaceEntry > > NameSpaceMap; class XMLOFF_DLLPUBLIC SvXMLNamespaceMap { - const OUString sXMLNS; - const OUString sEmpty; + OUString sXMLNS; NameSpaceHash aNameHash; mutable NameSpaceHash aNameCache; -- cgit