[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 3 commits - cppu/source cppu/util include/com include/uno oox/source sax/source
Noel Grandin
noel at peralex.com
Thu Oct 2 04:35:03 PDT 2014
cppu/source/uno/destr.hxx | 55 +++++++++++++++++++++-------------
cppu/source/uno/sequence.cxx | 8 ++++
cppu/util/cppu.map | 5 +++
include/com/sun/star/uno/Sequence.hxx | 9 +++--
include/uno/sequence2.h | 14 ++++++++
oox/source/token/tokenmap.cxx | 2 -
sax/source/tools/fastserializer.cxx | 33 +++++++++++++++++++-
7 files changed, 100 insertions(+), 26 deletions(-)
New commits:
commit 0f2ca932598a4026d71d6e548878fb8225e5e621
Author: Noel Grandin <noel at peralex.com>
Date: Tue Sep 30 16:13:47 2014 +0200
optimise UNO Sequence destructor
to avoid expensive function calls until the refcount reaches 0
Signed-off-by: Stephan Bergmann <sbergman at 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
(cherry picked from commit d8be5a55760b01efa32708411c6e47fe74600edc)
diff --git a/cppu/source/uno/destr.hxx b/cppu/source/uno/destr.hxx
index 9cce1c6..95f496e 100644
--- a/cppu/source/uno/destr.hxx
+++ b/cppu/source/uno/destr.hxx
@@ -19,6 +19,10 @@
#ifndef INCLUDED_CPPU_SOURCE_UNO_DESTR_HXX
#define INCLUDED_CPPU_SOURCE_UNO_DESTR_HXX
+#include <sal/config.h>
+
+#include <cassert>
+
#include "prim.hxx"
@@ -255,38 +259,47 @@ inline sal_Int32 idestructElements(
}
}
-
-inline void idestructSequence(
+inline void idestroySequence(
uno_Sequence * pSeq,
typelib_TypeDescriptionReference * pType,
typelib_TypeDescription * pTypeDescr,
uno_ReleaseFunc release )
{
- if (osl_atomic_decrement( &pSeq->nRefCount ) == 0)
+ assert(pSeq != nullptr);
+ assert(pSeq->nRefCount == 0);
+ if (pSeq->nElements > 0)
{
- if (pSeq->nElements > 0)
+ if (pTypeDescr)
{
- 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 );
- }
+ 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 );
}
+ ::rtl_freeMemory( pSeq );
}
+inline void idestructSequence(
+ uno_Sequence * pSeq,
+ typelib_TypeDescriptionReference * pType,
+ typelib_TypeDescription * pTypeDescr,
+ uno_ReleaseFunc release )
+{
+ if (osl_atomic_decrement( &pSeq->nRefCount ) == 0)
+ {
+ idestroySequence(pSeq, pType, pTypeDescr, release);
+ }
+}
inline void _destructData(
void * pValue,
diff --git a/cppu/source/uno/sequence.cxx b/cppu/source/uno/sequence.cxx
index cbd4369..9523a68 100644
--- a/cppu/source/uno/sequence.cxx
+++ b/cppu/source/uno/sequence.cxx
@@ -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: */
diff --git a/cppu/util/cppu.map b/cppu/util/cppu.map
index 6c8095b..df724a5 100644
--- a/cppu/util/cppu.map
+++ b/cppu/util/cppu.map
@@ -145,6 +145,11 @@ UDK_3.3 { # OOo 2.4
cppu_unsatisfied_iset_msg;
} UDK_3.2;
+LIBO_UDK_4.4 { # symbols available in >= LibO 4.4
+ global:
+ uno_type_sequence_destroy;
+} UDK_3.3;
+
# Unique libstdc++ symbols:
GLIBCXX_3.4 {
global:
diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx
index ba3b8c1..1ee59ae 100644
--- a/include/com/sun/star/uno/Sequence.hxx
+++ b/include/com/sun/star/uno/Sequence.hxx
@@ -95,9 +95,12 @@ inline Sequence< E >::Sequence( sal_Int32 len )
template< class E >
inline Sequence< E >::~Sequence()
{
- const Type & rType = ::cppu::getTypeFavourUnsigned( this );
- ::uno_type_destructData(
- this, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
+ if (osl_atomic_decrement( &_pSequence->nRefCount ) == 0)
+ {
+ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
+ uno_type_sequence_destroy(
+ _pSequence, rType.getTypeLibType(), (uno_ReleaseFunc)cpp_release );
+ }
}
template< class E >
diff --git a/include/uno/sequence2.h b/include/uno/sequence2.h
index 42208f0..3b55ba0 100644
--- a/include/uno/sequence2.h
+++ b/include/uno/sequence2.h
@@ -172,6 +172,20 @@ CPPU_DLLPUBLIC sal_Bool SAL_CALL uno_type_sequence_realloc(
uno_ReleaseFunc release )
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
}
#endif
commit 03e4df3acda31bd0e44365e5539be49cb415a10e
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Thu Oct 2 10:26:00 2014 +0200
maTokenNames.size() is constant: use it and be a bit faster
Change-Id: I39a6e2badf0c159e87763e2782bc89f0ee6068ec
diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx
index 880d5c6..dcd7284 100644
--- a/oox/source/token/tokenmap.cxx
+++ b/oox/source/token/tokenmap.cxx
@@ -82,7 +82,7 @@ sal_Int32 TokenMap::getTokenFromUnicode( const OUString& rUnicodeName ) const
Sequence< sal_Int8 > TokenMap::getUtf8TokenName( sal_Int32 nToken ) const
{
- if( (0 <= nToken) && (static_cast< size_t >( nToken ) < maTokenNames.size()) )
+ if( (0 <= nToken) && (static_cast< size_t >( nToken ) < XML_TOKEN_COUNT) )
return maTokenNames[ static_cast< size_t >( nToken ) ];
return Sequence< sal_Int8 >();
}
commit 4c78c5ed5aba4f0ca7c5913a1856e7df07afbc69
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Thu Oct 2 12:02:40 2014 +0200
FastSerializer: Faster write(OUString): add ascii check
Saves about 80m pcycles for 180k calls.
Change-Id: I9c9b3bf5a076df56d1b5b87f0a85ac3404abe8a4
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index 7afdc4d..37798d2 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -53,6 +53,15 @@ static const char sEqualSignAndQuote[] = "=\"";
static const char sSpace[] = " ";
static const char sXmlHeader[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+static bool lcl_isAscii(const OUString& sStr)
+{
+ for (sal_Int32 i = 0; i < sStr.getLength(); ++i)
+ if (sStr[i] & 0x80)
+ return false;
+
+ return true;
+}
+
namespace sax_fastparser {
FastSaxSerializer::FastSaxSerializer( const css::uno::Reference< css::io::XOutputStream >& xOutputStream )
: maCachedOutputStream()
@@ -72,7 +81,29 @@ namespace sax_fastparser {
void FastSaxSerializer::write( const OUString& sOutput, bool bEscape )
{
- write( OUStringToOString(sOutput, RTL_TEXTENCODING_UTF8), bEscape );
+ if (!lcl_isAscii(sOutput))
+ {
+ write( OUStringToOString(sOutput, RTL_TEXTENCODING_UTF8), bEscape );
+ return ;
+ }
+
+ for (sal_Int32 i = 0; i < sOutput.getLength(); ++i)
+ {
+ char c = sOutput[ i ];
+ if (bEscape) switch( c )
+ {
+ case '<': writeBytes( "<", 4 ); break;
+ case '>': writeBytes( ">", 4 ); break;
+ case '&': writeBytes( "&", 5 ); break;
+ case '\'': writeBytes( "'", 6 ); break;
+ case '"': writeBytes( """, 6 ); break;
+ case '\n': writeBytes( "
", 5 ); break;
+ case '\r': writeBytes( "
", 5 ); break;
+ default: writeBytes( &c, 1 ); break;
+ }
+ else
+ writeBytes( &c, 1 );
+ }
}
void FastSaxSerializer::write( const OString& sOutput, bool bEscape )
More information about the Libreoffice-commits
mailing list