diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-16 13:10:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-18 15:10:52 +0200 |
commit | 787525a314de9c8178d0fedcd71ddbd08ec41a55 (patch) | |
tree | 06672e9e203f5a3a8ea53c4a3c4b0bb0767cfaa2 /xmloff/source | |
parent | ecf456d067346d49d7e2a366434477fa7de06d8a (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/core/nmspmap.cxx | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/xmloff/source/core/nmspmap.cxx b/xmloff/source/core/nmspmap.cxx index 248a36213ee4..669d0cc9f727 100644 --- a/xmloff/source/core/nmspmap.cxx +++ b/xmloff/source/core/nmspmap.cxx @@ -46,6 +46,8 @@ using namespace ::xmloff::token; * Martin 13/06/01 */ +static const OUString sEmpty; + SvXMLNamespaceMap::SvXMLNamespaceMap() : sXMLNS( GetXMLToken ( XML_XMLNS ) ) { @@ -302,47 +304,50 @@ sal_uInt16 SvXMLNamespaceMap::GetKeyByAttrName_( const OUString& rAttrName, } else { - rtl::Reference<NameSpaceEntry> xEntry(new NameSpaceEntry); + OUString sEntryPrefix, sEntryName; sal_Int32 nColonPos = rAttrName.indexOf( ':' ); if( -1 == nColonPos ) { // case: no ':' found -> default namespace - xEntry->sPrefix.clear(); - xEntry->sName = rAttrName; + sEntryName = rAttrName; } else { // normal case: ':' found -> get prefix/suffix - xEntry->sPrefix = rAttrName.copy( 0L, nColonPos ); - xEntry->sName = rAttrName.copy( nColonPos + 1 ); + sEntryPrefix = rAttrName.copy( 0L, nColonPos ); + sEntryName = rAttrName.copy( nColonPos + 1 ); } if( pPrefix ) - *pPrefix = xEntry->sPrefix; + *pPrefix = sEntryPrefix; if( pLocalName ) - *pLocalName = xEntry->sName; + *pLocalName = sEntryName; - NameSpaceHash::const_iterator aIter = aNameHash.find( xEntry->sPrefix ); + NameSpaceHash::const_iterator aIter = aNameHash.find( sEntryPrefix ); if ( aIter != aNameHash.end() ) { // found: retrieve namespace key - nKey = xEntry->nKey = (*aIter).second->nKey; + nKey = (*aIter).second->nKey; if ( pNamespace ) *pNamespace = (*aIter).second->sName; } - else if ( xEntry->sPrefix == sXMLNS ) + else if ( sEntryPrefix == sXMLNS ) // not found, but xmlns prefix: return xmlns 'namespace' - nKey = xEntry->nKey = XML_NAMESPACE_XMLNS; + nKey = XML_NAMESPACE_XMLNS; else if( nColonPos == -1 ) // not found, and no namespace: 'namespace' none - nKey = xEntry->nKey = XML_NAMESPACE_NONE; + nKey = XML_NAMESPACE_NONE; else - nKey = xEntry->nKey = XML_NAMESPACE_UNKNOWN; + nKey = XML_NAMESPACE_UNKNOWN; if (bCache) { - aNameCache.emplace(rAttrName, xEntry); + rtl::Reference<NameSpaceEntry> xEntry(new NameSpaceEntry); + xEntry->sPrefix = std::move(sEntryPrefix); + xEntry->sName = std::move(sEntryName); + xEntry->nKey = std::move(nKey); + aNameCache.emplace(rAttrName, std::move(xEntry)); } } |