[Libreoffice-commits] core.git: 2 commits - sax/source toolkit/Library_tk.mk

Michael Meeks michael.meeks at collabora.com
Fri Oct 11 06:20:45 PDT 2013


 sax/source/fastparser/fastparser.cxx |   28 +++++++++++++++++++++++-----
 sax/source/fastparser/fastparser.hxx |    3 +++
 toolkit/Library_tk.mk                |    8 --------
 3 files changed, 26 insertions(+), 13 deletions(-)

New commits:
commit f1702566befe8771210194d767dbea0022d0eae3
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Oct 11 13:50:20 2013 +0100

    fastparser: don't allocate uno::Sequences when we don't need to.
    
    Change-Id: Ic2fff8cabbc077b6fc9dabffd2c6fcf555152b11

diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 3477996..6b793db 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -201,6 +201,7 @@ Entity::~Entity()
 FastSaxParser::FastSaxParser()
 {
     mxDocumentLocator.set( new FastLocatorImpl( this ) );
+    maUtf8Buffer.realloc( mnUtf8BufferSize );
 }
 
 // --------------------------------------------------------------------
@@ -259,19 +260,36 @@ void FastSaxParser::DefineNamespace( const OString& rPrefix, const sal_Char* pNa
 
 sal_Int32 FastSaxParser::GetToken( const OString& rToken )
 {
-    Sequence< sal_Int8 > aSeq( (sal_Int8*)rToken.getStr(), rToken.getLength() );
-
-    return getEntity().mxTokenHandler->getTokenFromUTF8( aSeq );
+    return GetToken( rToken.getStr(), rToken.getLength() );
 }
 
 sal_Int32 FastSaxParser::GetToken( const sal_Char* pToken, sal_Int32 nLen /* = 0 */ )
 {
+    sal_Int32 nRet;
+
     if( !nLen )
         nLen = strlen( pToken );
 
-    Sequence< sal_Int8 > aSeq( (sal_Int8*)pToken, nLen );
+    if ( nLen < mnUtf8BufferSize )
+    {
+        // Get intimiate with the underlying sequence cf. sal/types.h
+        sal_Sequence *pSeq = maUtf8Buffer.get();
+
+        sal_Int32 nPreRefCount = pSeq->nRefCount;
+
+        pSeq->nElements = nLen;
+        memcpy( pSeq->elements, pToken, nLen );
+        nRet = getEntity().mxTokenHandler->getTokenFromUTF8( maUtf8Buffer );
 
-    return getEntity().mxTokenHandler->getTokenFromUTF8( aSeq );
+        (void)nPreRefCount; // for non-debug mode.
+        assert( pSeq->nRefCount == nPreRefCount ); // callee must not take ref.
+    }
+    else
+    {
+        Sequence< sal_Int8 > aSeq( (sal_Int8*)pToken, nLen ); // heap allocate & free
+        nRet = getEntity().mxTokenHandler->getTokenFromUTF8( aSeq );
+    }
+    return nRet;
 }
 
 // --------------------------------------------------------------------
diff --git a/sax/source/fastparser/fastparser.hxx b/sax/source/fastparser/fastparser.hxx
index dab438f..e75ee0f 100644
--- a/sax/source/fastparser/fastparser.hxx
+++ b/sax/source/fastparser/fastparser.hxx
@@ -154,6 +154,9 @@ private:
 
     ParserData maData;                      /// Cached parser configuration for next call of parseStream().
     ::std::stack< Entity > maEntities;      /// Entity stack for each call of parseStream().
+
+    static const int mnUtf8BufferSize = 128;
+    ::css::uno::Sequence< sal_Int8 > maUtf8Buffer; /// avoid constantly re-allocating this
 };
 
 }
commit 0489d6b7d36dff230aa9f440ae54eb60c3643662
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Oct 8 14:47:29 2013 +0100

    remove redundant X11 linkage in toolkit.
    
    Change-Id: I73badeb7763da155296ff5bb673b36411e10791b

diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk
index 57a0bd3..14d84ee 100644
--- a/toolkit/Library_tk.mk
+++ b/toolkit/Library_tk.mk
@@ -124,14 +124,6 @@ $(eval $(call gb_Library_add_cxxflags,tk,\
     $(gb_OBJCXXFLAGS)))
 endif
 
-ifeq (,$(ENABLE_HEADLESS))
-ifneq (,$(filter LINUX DRAGONFLY OPENBSD FREEBSD NETBSD, $(OS)))
-$(eval $(call gb_Library_add_libs,tk,\
-    -lX11 \
-))
-endif
-endif
-
 ifeq ($(OS),ANDROID)
 $(eval $(call gb_Library_use_libraries,tk,\
     libotouch \


More information about the Libreoffice-commits mailing list