tdf#125688 removing XWeak support from SvXMLImportContext
shaves 2% off the load time
Change-Id: Icac00389dfcc3339fe4faf1731e9eeb3ff8d0f0c
Reviewed-on: https://gerrit.libreoffice.org/82139
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/include/xmloff/xmlictxt.hxx b/include/xmloff/xmlictxt.hxx
index 9cf531b..8dc67da 100644
--- a/include/xmloff/xmlictxt.hxx
+++ b/include/xmloff/xmlictxt.hxx
@@ -24,8 +24,8 @@
#include <xmloff/dllapi.h>
#include <sal/types.h>
#include <com/sun/star/xml/sax/XFastContextHandler.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <rtl/ustring.hxx>
#include <cppuhelper/implbase.hxx>
#include <xmloff/nmspmap.hxx>
#include <memory>
@@ -37,15 +37,20 @@ class SvXMLImportContext;
typedef rtl::Reference<SvXMLImportContext> SvXMLImportContextRef;
class XMLOFF_DLLPUBLIC SvXMLImportContext : public cppu::WeakImplHelper< css::xml::sax::XFastContextHandler >
/**
This class deliberately does not support XWeak, to improve performance when loading
large documents.
*/
class XMLOFF_DLLPUBLIC SvXMLImportContext : public css::xml::sax::XFastContextHandler,
public css::lang::XTypeProvider
{
friend class SvXMLImport;
SvXMLImport& mrImport;
sal_uInt16 const mnPrefix;
OUString const maLocalName;
oslInterlockedCount m_nRefCount;
SvXMLImport& mrImport;
sal_uInt16 mnPrefix;
OUString maLocalName;
std::unique_ptr<SvXMLNamespaceMap> m_pRewindMap;
SAL_DLLPRIVATE std::unique_ptr<SvXMLNamespaceMap> TakeRewindMap() { return std::move(m_pRewindMap); }
@@ -74,7 +79,7 @@ public:
* ends. By default, nothing is done.
* Note that virtual methods cannot be used inside destructors. Use
* EndElement instead if this is required. */
virtual ~SvXMLImportContext() override;
virtual ~SvXMLImportContext();
/** Create a children element context. By default, the import's
* CreateContext method is called to create a new default context. */
@@ -115,6 +120,17 @@ public:
const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
virtual void SAL_CALL characters(const OUString & aChars) override;
// XInterface
virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) final override;
virtual void SAL_CALL acquire() throw () final override
{ osl_atomic_increment(&m_nRefCount); }
virtual void SAL_CALL release() throw () final override
{ if (osl_atomic_decrement(&m_nRefCount) == 0) delete this; }
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) final override;
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) final override;
};
#endif // INCLUDED_XMLOFF_XMLICTXT_HXX
diff --git a/xmloff/source/core/xmlictxt.cxx b/xmloff/source/core/xmlictxt.cxx
index fb4e64e..8e31d49 100644
--- a/xmloff/source/core/xmlictxt.cxx
+++ b/xmloff/source/core/xmlictxt.cxx
@@ -22,19 +22,22 @@
#include <xmloff/xmlictxt.hxx>
#include <sax/fastattribs.hxx>
#include <comphelper/attributelist.hxx>
#include <cppuhelper/queryinterface.hxx>
using namespace ::com::sun::star;
SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
const OUString& rLName )
: mrImport(rImp)
: m_nRefCount(0)
, mrImport(rImp)
, mnPrefix(nPrfx)
, maLocalName(rLName)
{
}
SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp )
: mrImport(rImp)
: m_nRefCount(0)
, mrImport(rImp)
, mnPrefix(0)
{
}
@@ -143,4 +146,27 @@ void SAL_CALL SvXMLImportContext::characters(const OUString &rChars)
mrImport.Characters( rChars );
}
// XInterface
css::uno::Any SAL_CALL SvXMLImportContext::queryInterface( const css::uno::Type& aType )
{
css::uno::Any a = ::cppu::queryInterface(
aType,
static_cast< XFastContextHandler* >(this),
static_cast< XTypeProvider* >(this));
return a;
}
// XTypeProvider
css::uno::Sequence< css::uno::Type > SAL_CALL SvXMLImportContext::getTypes()
{
return { cppu::UnoType<XFastContextHandler>::get(),
cppu::UnoType<XTypeProvider>::get() };
}
css::uno::Sequence< sal_Int8 > SAL_CALL SvXMLImportContext::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */