optimise UNO Sequence destructor
to avoid expensive function calls until the refcount reaches 0 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>, slightly changing it to add a uno_type_sequence_destroy to uno/sequence2.h instead of a uno_type_destructSequence to uno/data.h. Change-Id: I3bbff3294f2b515fc3c68c4c6c1cb16829f5cc44
This commit is contained in:
committed by
Stephan Bergmann
parent
18ceb207dd
commit
d8be5a5576
@@ -19,6 +19,10 @@
|
|||||||
#ifndef INCLUDED_CPPU_SOURCE_UNO_DESTR_HXX
|
#ifndef INCLUDED_CPPU_SOURCE_UNO_DESTR_HXX
|
||||||
#define INCLUDED_CPPU_SOURCE_UNO_DESTR_HXX
|
#define INCLUDED_CPPU_SOURCE_UNO_DESTR_HXX
|
||||||
|
|
||||||
|
#include <sal/config.h>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include "prim.hxx"
|
#include "prim.hxx"
|
||||||
|
|
||||||
|
|
||||||
@@ -255,6 +259,35 @@ inline sal_Int32 idestructElements(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void idestroySequence(
|
||||||
|
uno_Sequence * pSeq,
|
||||||
|
typelib_TypeDescriptionReference * pType,
|
||||||
|
typelib_TypeDescription * pTypeDescr,
|
||||||
|
uno_ReleaseFunc release )
|
||||||
|
{
|
||||||
|
assert(pSeq != nullptr);
|
||||||
|
assert(pSeq->nRefCount == 0);
|
||||||
|
if (pSeq->nElements > 0)
|
||||||
|
{
|
||||||
|
if (pTypeDescr)
|
||||||
|
{
|
||||||
|
idestructElements(
|
||||||
|
pSeq->elements,
|
||||||
|
((typelib_IndirectTypeDescription *) pTypeDescr)->pType, 0,
|
||||||
|
pSeq->nElements, release );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TYPELIB_DANGER_GET( &pTypeDescr, pType );
|
||||||
|
idestructElements(
|
||||||
|
pSeq->elements,
|
||||||
|
((typelib_IndirectTypeDescription *) pTypeDescr)->pType, 0,
|
||||||
|
pSeq->nElements, release );
|
||||||
|
TYPELIB_DANGER_RELEASE( pTypeDescr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
::rtl_freeMemory( pSeq );
|
||||||
|
}
|
||||||
|
|
||||||
inline void idestructSequence(
|
inline void idestructSequence(
|
||||||
uno_Sequence * pSeq,
|
uno_Sequence * pSeq,
|
||||||
@@ -264,30 +297,10 @@ inline void idestructSequence(
|
|||||||
{
|
{
|
||||||
if (osl_atomic_decrement( &pSeq->nRefCount ) == 0)
|
if (osl_atomic_decrement( &pSeq->nRefCount ) == 0)
|
||||||
{
|
{
|
||||||
if (pSeq->nElements > 0)
|
idestroySequence(pSeq, pType, pTypeDescr, release);
|
||||||
{
|
|
||||||
if (pTypeDescr)
|
|
||||||
{
|
|
||||||
idestructElements(
|
|
||||||
pSeq->elements,
|
|
||||||
((typelib_IndirectTypeDescription *) pTypeDescr)->pType, 0,
|
|
||||||
pSeq->nElements, release );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TYPELIB_DANGER_GET( &pTypeDescr, pType );
|
|
||||||
idestructElements(
|
|
||||||
pSeq->elements,
|
|
||||||
((typelib_IndirectTypeDescription *) pTypeDescr)->pType, 0,
|
|
||||||
pSeq->nElements, release );
|
|
||||||
TYPELIB_DANGER_RELEASE( pTypeDescr );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::rtl_freeMemory( pSeq );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void _destructData(
|
inline void _destructData(
|
||||||
void * pValue,
|
void * pValue,
|
||||||
typelib_TypeDescriptionReference * pType,
|
typelib_TypeDescriptionReference * pType,
|
||||||
|
@@ -920,6 +920,14 @@ void SAL_CALL uno_type_sequence_assign(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uno_type_sequence_destroy(
|
||||||
|
uno_Sequence * sequence, typelib_TypeDescriptionReference * type,
|
||||||
|
uno_ReleaseFunc release)
|
||||||
|
SAL_THROW_EXTERN_C()
|
||||||
|
{
|
||||||
|
idestroySequence(sequence, type, nullptr, release);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -145,6 +145,11 @@ UDK_3.3 { # OOo 2.4
|
|||||||
cppu_unsatisfied_iset_msg;
|
cppu_unsatisfied_iset_msg;
|
||||||
} UDK_3.2;
|
} UDK_3.2;
|
||||||
|
|
||||||
|
LIBO_UDK_4.4 { # symbols available in >= LibO 4.4
|
||||||
|
global:
|
||||||
|
uno_type_sequence_destroy;
|
||||||
|
} UDK_3.3;
|
||||||
|
|
||||||
# Unique libstdc++ symbols:
|
# Unique libstdc++ symbols:
|
||||||
GLIBCXX_3.4 {
|
GLIBCXX_3.4 {
|
||||||
global:
|
global:
|
||||||
|
@@ -95,9 +95,12 @@ inline Sequence< E >::Sequence( sal_Int32 len )
|
|||||||
template< class E >
|
template< class E >
|
||||||
inline Sequence< E >::~Sequence()
|
inline Sequence< E >::~Sequence()
|
||||||
{
|
{
|
||||||
const Type & rType = ::cppu::getTypeFavourUnsigned( this );
|
if (osl_atomic_decrement( &_pSequence->nRefCount ) == 0)
|
||||||
::uno_type_destructData(
|
{
|
||||||
this, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
|
const Type & rType = ::cppu::getTypeFavourUnsigned( this );
|
||||||
|
uno_type_sequence_destroy(
|
||||||
|
_pSequence, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class E >
|
template< class E >
|
||||||
|
@@ -172,6 +172,20 @@ CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_sequence_realloc(
|
|||||||
uno_ReleaseFunc release )
|
uno_ReleaseFunc release )
|
||||||
SAL_THROW_EXTERN_C();
|
SAL_THROW_EXTERN_C();
|
||||||
|
|
||||||
|
/** Destroy a sequence whose reference count has dropped to zero.
|
||||||
|
|
||||||
|
@param sequence must be non-null, sequence->nRefCount must be zero
|
||||||
|
@param type the type of the sequence, must be non-null
|
||||||
|
@param release function called each time an interface needs to be release,
|
||||||
|
must be non-null
|
||||||
|
|
||||||
|
@since LibreOffice 4.4
|
||||||
|
*/
|
||||||
|
CPPU_DLLPUBLIC void SAL_CALL uno_type_sequence_destroy(
|
||||||
|
uno_Sequence * sequence, struct _typelib_TypeDescriptionReference * type,
|
||||||
|
uno_ReleaseFunc release)
|
||||||
|
SAL_THROW_EXTERN_C();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user