[Libreoffice-commits] core.git: include/xmloff xmloff/source
Mohammed Abdul Azeem
azeemmysore at gmail.com
Mon May 22 12:00:24 UTC 2017
include/xmloff/xmlimp.hxx | 2 ++
xmloff/source/core/xmlictxt.cxx | 16 +++++++++++-----
xmloff/source/core/xmlimp.cxx | 10 +++++++---
3 files changed, 20 insertions(+), 8 deletions(-)
New commits:
commit a7bfced28c526ca603cde3c1ac74ea842320bd7c
Author: Mohammed Abdul Azeem <azeemmysore at gmail.com>
Date: Sat Feb 11 01:50:34 2017 +0530
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 at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index f7137715ced3..37b1d1589d88 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -222,6 +222,8 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
bool isFastContext;
css::uno::Reference< css::xml::sax::XFastParser > mxParser;
rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler;
+ rtl::Reference < comphelper::AttributeList > maAttrList;
+ rtl::Reference < comphelper::AttributeList > maNamespaceAttrList;
css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler;
css::uno::Reference< css::xml::sax::XFastTokenHandler > mxTokenHandler;
std::unordered_map< sal_Int32, OUString > maNamespaceMap;
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));
More information about the Libreoffice-commits
mailing list