diff options
author | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2017-02-11 01:50:34 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2017-05-22 14:00:00 +0200 |
commit | a7bfced28c526ca603cde3c1ac74ea842320bd7c (patch) | |
tree | c710411cc51762f9937cbbc01f880cdd80f71e8c /xmloff | |
parent | 7539c77fd49889015ad3a952009e33fac5324df6 (diff) |
Optimizations:
This avoids a lot of repeated allocation and freeing
of memory for AttributeList.
Change-Id: I97e44e633ed9880f37665f71e4dec3e74085cb09
Reviewed-on: https://gerrit.libreoffice.org/34134
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmlictxt.cxx | 16 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 10 |
2 files changed, 18 insertions, 8 deletions
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx index 63025083d78f..9a1d5bc0ea62 100644 --- a/xmloff/source/core/xmlictxt.cxx +++ b/xmloff/source/core/xmlictxt.cxx @@ -78,8 +78,14 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & rPrefix, const uno::Reference< xml::sax::XFastAttributeList > & Attribs) { OUString elementName; - rtl::Reference < comphelper::AttributeList > rAttrList = new comphelper::AttributeList; - mrImport.maNamespaceHandler->addNSDeclAttributes( rAttrList ); + + if ( mrImport.maAttrList.is() ) + mrImport.maAttrList->Clear(); + else + mrImport.maAttrList = new comphelper::AttributeList; + + mrImport.maNamespaceHandler->addNSDeclAttributes( mrImport.maAttrList ); + if ( !rPrefix.isEmpty() ) elementName = rPrefix + ":" + rLocalName; else @@ -102,7 +108,7 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & rPrefix, if ( !rAttrNamespacePrefix.isEmpty() ) sAttrName = rAttrNamespacePrefix + ":" + sAttrName; - rAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue ); + mrImport.maAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue ); } uno::Sequence< xml::Attribute > unknownAttribs = Attribs->getUnknownAttributes(); @@ -115,11 +121,11 @@ void SAL_CALL SvXMLImportContext::startUnknownElement(const OUString & rPrefix, if ( !rAttrNamespacePrefix.isEmpty() ) sAttrName = rAttrNamespacePrefix + ":" + sAttrName; - rAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue ); + mrImport.maAttrList->AddAttribute( sAttrName, "CDATA", rAttrValue ); } } - mrImport.startElement( elementName, rAttrList.get() ); + mrImport.startElement( elementName, mrImport.maAttrList.get() ); } void SAL_CALL SvXMLImportContext::endFastElement(sal_Int32 nElement) diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index eba9d2ad21b6..2d489bc1cdb4 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -818,10 +818,14 @@ void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element, if ( isFastContext ) { - rtl::Reference < comphelper::AttributeList > rAttrList = new comphelper::AttributeList; - maNamespaceHandler->addNSDeclAttributes( rAttrList ); + if ( maNamespaceAttrList.is() ) + maNamespaceAttrList->Clear(); + else + maNamespaceAttrList = new comphelper::AttributeList; + + maNamespaceHandler->addNSDeclAttributes( maNamespaceAttrList ); std::unique_ptr<SvXMLNamespaceMap> pRewindMap( - processNSAttributes(rAttrList.get())); + processNSAttributes( maNamespaceAttrList.get() )); SvXMLImportContext *pContext = dynamic_cast<SvXMLImportContext*>( xContext.get() ); if( pContext && pRewindMap ) pContext->PutRewindMap(std::move(pRewindMap)); |