[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 3 commits - sax/source sc/source

2014-10-02 Thread Matúš Kukan
 sax/source/tools/fastserializer.cxx  |   28 ++-
 sax/source/tools/fastserializer.hxx  |5 
 sax/source/tools/fshelper.cxx|8 ---
 sc/source/filter/excel/xecontent.cxx |   12 +--
 sc/source/filter/excel/xeextlst.cxx  |2 -
 sc/source/filter/excel/xestream.cxx  |7 --
 sc/source/filter/excel/xetable.cxx   |2 -
 sc/source/filter/inc/xeroot.hxx  |3 ++
 sc/source/filter/inc/xestream.hxx|3 +-
 sc/source/filter/xcl97/XclExpChangeTrack.cxx |2 -
 10 files changed, 28 insertions(+), 44 deletions(-)

New commits:
commit 5a87aae25b05818a961beb34021db67f17336ab8
Author: Matúš Kukan matus.ku...@collabora.com
Date:   Wed Oct 1 18:45:23 2014 +0200

FastSerializer: Simplify a bit

Change-Id: I7dee908f5441ad34128d688e1008fd6ffad2ab3f

diff --git a/sax/source/tools/fastserializer.cxx 
b/sax/source/tools/fastserializer.cxx
index 8ea04d2..7afdc4d 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -19,7 +19,9 @@
 
 #include fastserializer.hxx
 
+#include com/sun/star/xml/sax/FastTokenHandler.hpp
 #include rtl/ustrbuf.hxx
+#include comphelper/processfactory.hxx
 #include comphelper/sequenceasvector.hxx
 
 #include string.h
@@ -52,11 +54,14 @@ static const char sSpace[] =  ;
 static const char sXmlHeader[] = ?xml version=\1.0\ encoding=\UTF-8\ 
standalone=\yes\?\n;
 
 namespace sax_fastparser {
-FastSaxSerializer::FastSaxSerializer( )
+FastSaxSerializer::FastSaxSerializer( const css::uno::Reference 
css::io::XOutputStream  xOutputStream )
 : maCachedOutputStream()
-, mxFastTokenHandler()
 , maMarkStack()
 {
+mxFastTokenHandler = css::xml::sax::FastTokenHandler::create(
+::comphelper::getProcessComponentContext());
+assert(xOutputStream.is()); // cannot do anything without that
+maCachedOutputStream.setOutputStream( xOutputStream );
 }
 FastSaxSerializer::~FastSaxSerializer() {}
 
@@ -189,21 +194,11 @@ namespace sax_fastparser {
 writeBytes(sSlashAndClosingBracket, N_CHARS(sSlashAndClosingBracket));
 }
 
-void FastSaxSerializer::setOutputStream( const 
::com::sun::star::uno::Reference ::com::sun::star::io::XOutputStream  
xOutputStream )
-{
-maCachedOutputStream.setOutputStream( xOutputStream );
-}
-
 ::com::sun::star::uno::Reference ::com::sun::star::io::XOutputStream  
FastSaxSerializer::getOutputStream()
 {
 return maCachedOutputStream.getOutputStream();
 }
 
-void FastSaxSerializer::setFastTokenHandler( const 
::com::sun::star::uno::Reference ::com::sun::star::xml::sax::XFastTokenHandler 
 xFastTokenHandler )
-{
-mxFastTokenHandler = xFastTokenHandler;
-}
-
 void FastSaxSerializer::writeTokenValueList()
 {
 #ifdef DBG_UTIL
diff --git a/sax/source/tools/fastserializer.hxx 
b/sax/source/tools/fastserializer.hxx
index 6e81c91..60ef71b 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -48,7 +48,7 @@ class FastSaxSerializer
 typedef ::com::sun::star::uno::Sequence ::sal_Int32  Int32Sequence;
 
 public:
-FastSaxSerializer();
+FastSaxSerializer( const css::uno::Reference css::io::XOutputStream  
xOutputStream );
 ~FastSaxSerializer();
 
 ::com::sun::star::uno::Reference ::com::sun::star::io::XOutputStream  
getOutputStream();
@@ -106,9 +106,6 @@ public:
 */
 void singleFastElement( ::sal_Int32 Element, FastAttributeList* pAttrList 
= NULL );
 
-void setOutputStream( const ::com::sun::star::uno::Reference 
::com::sun::star::io::XOutputStream  xOutputStream );
-void setFastTokenHandler( const ::com::sun::star::uno::Reference 
::com::sun::star::xml::sax::XFastTokenHandler  xFastTokenHandler );
-
 // C++ helpers
 void writeId( ::sal_Int32 Element );
 OString getId( ::sal_Int32 Element );
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index 2227352..55be646 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -19,9 +19,7 @@
 
 #include sax/fshelper.hxx
 #include fastserializer.hxx
-#include com/sun/star/xml/sax/FastTokenHandler.hpp
 #include com/sun/star/xml/sax/XFastTokenHandler.hpp
-#include comphelper/processfactory.hxx
 #include rtl/ustrbuf.hxx
 
 using namespace ::com::sun::star;
@@ -30,12 +28,8 @@ using namespace ::com::sun::star::uno;
 namespace sax_fastparser {
 
 FastSerializerHelper::FastSerializerHelper(const Reference io::XOutputStream 
 xOutputStream, bool bWriteHeader ) :
-mpSerializer(new FastSaxSerializer())
+mpSerializer(new FastSaxSerializer(xOutputStream))
 {
-Reference XComponentContext  xContext( 
::comphelper::getProcessComponentContext(), UNO_SET_THROW );
-mpSerializer-setFastTokenHandler( 
css::xml::sax::FastTokenHandler::create(xContext) );
-assert(xOutputStream.is()); // 

[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 3 commits - sax/source sc/source

2014-10-01 Thread Matúš Kukan
 sax/source/tools/CachedOutputStream.hxx |   46 -
 sax/source/tools/fastserializer.cxx |9 +--
 sc/source/core/tool/address.cxx |   86 
 3 files changed, 60 insertions(+), 81 deletions(-)

New commits:
commit 077b5381570c5bea2281267ad1d2b3f5ab2beac6
Author: Matúš Kukan matus.ku...@collabora.com
Date:   Tue Sep 30 15:13:22 2014 +0200

Use OUStringBuffers for performance reasons.

Saves 120m pcycles in just 250k calls to ScAddress::Format.

Change-Id: Ibf20cf0843a47cf0fa37a38c4fecf1ae1560412c

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 6a37952..c8c8f18 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1656,50 +1656,50 @@ sal_uInt16 ScRange::ParseRows( const OUString rStr, 
ScDocument* pDoc,
 return (p != NULL  *p == '\0') ? nRes : 0;
 }
 
-static inline void lcl_a1_append_c ( OUString rString, int nCol, bool bIsAbs )
+static inline void lcl_a1_append_c ( OUStringBuffer rString, int nCol, bool 
bIsAbs )
 {
 if( bIsAbs )
-rString += $;
+rString.append($);
 ScColToAlpha( rString, sal::static_int_castSCCOL(nCol) );
 }
 
-static inline void lcl_a1_append_r ( OUString rString, int nRow, bool bIsAbs )
+static inline void lcl_a1_append_r ( OUStringBuffer rString, int nRow, bool 
bIsAbs )
 {
 if ( bIsAbs )
-rString += $;
-rString += OUString::number( nRow+1 );
+rString.append($);
+rString.append(OUString::number( nRow+1 ));
 }
 
-static inline void lcl_r1c1_append_c ( OUString rString, int nCol, bool 
bIsAbs,
+static inline void lcl_r1c1_append_c ( OUStringBuffer rString, int nCol, bool 
bIsAbs,
const ScAddress::Details rDetails )
 {
-rString += C;
+rString.append(C);
 if (bIsAbs)
 {
-rString += OUString::number( nCol + 1 );
+rString.append(OUString::number( nCol + 1 ));
 }
 else
 {
 nCol -= rDetails.nCol;
 if (nCol != 0) {
-rString += [ + OUString::number( nCol ) + ];
+rString.append([).append(OUString::number( nCol )).append(]);
 }
 }
 }
 
-static inline void lcl_r1c1_append_r ( OUString rString, int nRow, bool 
bIsAbs,
+static inline void lcl_r1c1_append_r ( OUStringBuffer rString, int nRow, bool 
bIsAbs,
const ScAddress::Details rDetails )
 {
-rString += R;
+rString.append(R);
 if (bIsAbs)
 {
-rString += OUString::number( nRow + 1 );
+rString.append(OUString::number( nRow + 1 ));
 }
 else
 {
 nRow -= rDetails.nRow;
 if (nRow != 0) {
-rString += [ + OUString::number( nRow ) + ];
+rString.append([).append(OUString::number( nRow )).append(]);
 }
 }
 }
@@ -1732,7 +1732,7 @@ static OUString getFileNameFromDoc( const ScDocument* 
pDoc )
 OUString ScAddress::Format(sal_uInt16 nFlags, const ScDocument* pDoc,
const Details rDetails) const
 {
-OUString r;
+OUStringBuffer r;
 if( nFlags  SCA_VALID )
 nFlags |= ( SCA_VALID_ROW | SCA_VALID_COL | SCA_VALID_TAB );
 if( pDoc  (nFlags  SCA_VALID_TAB ) )
@@ -1770,11 +1770,11 @@ OUString ScAddress::Format(sal_uInt16 nFlags, const 
ScDocument* pDoc,
 {
 default :
 case formula::FormulaGrammar::CONV_OOO:
-r += aDocName;
+r.append(aDocName);
 if( nFlags  SCA_TAB_ABSOLUTE )
-r += $;
-r += aTabName;
-r += .;
+r.append($);
+r.append(aTabName);
+r.append(.);
 break;
 
 case formula::FormulaGrammar::CONV_XL_A1:
@@ -1782,10 +1782,10 @@ OUString ScAddress::Format(sal_uInt16 nFlags, const 
ScDocument* pDoc,
 case formula::FormulaGrammar::CONV_XL_OOX:
 if (!aDocName.isEmpty())
 {
-r += [ + aDocName + ];
+r.append([).append(aDocName).append(]);
 }
-r += aTabName;
-r += !;
+r.append(aTabName);
+r.append(!);
 break;
 }
 }
@@ -1809,7 +1809,7 @@ OUString ScAddress::Format(sal_uInt16 nFlags, const 
ScDocument* pDoc,
 lcl_r1c1_append_c ( r, nCol, (nFlags  SCA_COL_ABSOLUTE) != 0, 
rDetails );
 break;
 }
-return r;
+return r.makeStringAndClear();
 }
 
 static void lcl_Split_DocTab( const ScDocument* pDoc,  SCTAB nTab,
@@ -1841,7 +1841,7 @@ static void lcl_Split_DocTab( const ScDocument* pDoc,  
SCTAB nTab,
 ScCompiler::CheckTabQuotes( rTabName, rDetails.eConv);
 }
 
-static void lcl_ScRange_Format_XL_Header( OUString rString, const ScRange 
rRange,
+static void lcl_ScRange_Format_XL_Header( OUStringBuffer rString, const