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

Matúš Kukan matus.kukan at collabora.com
Thu Sep 25 08:08:15 PDT 2014


 include/sax/fshelper.hxx            |    1 +
 sax/source/tools/fastserializer.cxx |   33 ++++++---------------------------
 sax/source/tools/fastserializer.hxx |    8 +++-----
 sax/source/tools/fshelper.cxx       |   17 ++++++++++++-----
 4 files changed, 22 insertions(+), 37 deletions(-)

New commits:
commit 700ac99d93c87d88bf5adf74ad10257d672d72e1
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Sep 25 17:06:22 2014 +0200

    FastSerializer: Have OString version of write() too.
    
    And remove characters() member function.
    
    Change-Id: Ifcedbb6d969b7b057ff378d2fbce09c2dde5ac18

diff --git a/include/sax/fshelper.hxx b/include/sax/fshelper.hxx
index 8a9f1cc..d83ce78 100644
--- a/include/sax/fshelper.hxx
+++ b/include/sax/fshelper.hxx
@@ -126,6 +126,7 @@ public:
 
     FastSerializerHelper* write(const char* value);
     FastSerializerHelper* write(const OUString& value);
+    FastSerializerHelper* write(const OString& value);
     FastSerializerHelper* write(sal_Int32 value);
     FastSerializerHelper* write(sal_Int64 value);
     FastSerializerHelper* write(double value);
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index a6b5afd..56b27af 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -99,9 +99,13 @@ namespace sax_fastparser {
         return sBuf.makeStringAndClear();
     }
 
-    void FastSaxSerializer::write( const OUString& s )
+    void FastSaxSerializer::write( const OUString& sOutput )
+    {
+        write( OUStringToOString(sOutput, RTL_TEXTENCODING_UTF8) );
+    }
+
+    void FastSaxSerializer::write( const OString& sOutput )
     {
-        OString sOutput( OUStringToOString( s, RTL_TEXTENCODING_UTF8 ) );
         writeBytes( Sequence< sal_Int8 >(
                     reinterpret_cast< const sal_Int8*>( sOutput.getStr() ),
                     sOutput.getLength() ) );
@@ -191,12 +195,6 @@ namespace sax_fastparser {
         writeBytes(toUnoSequence(maSlashAndClosingBracket));
     }
 
-    void SAL_CALL FastSaxSerializer::characters( const OUString& aChars )
-        throw (SAXException, RuntimeException)
-    {
-        write( aChars );
-    }
-
     void SAL_CALL FastSaxSerializer::setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream )
         throw (::com::sun::star::uno::RuntimeException)
     {
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index 45535f2..d754b98 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -100,10 +100,6 @@ public:
     void SAL_CALL singleFastElement( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs )
         throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
 
-    /// receives notification of character data.
-    void SAL_CALL characters( const OUString& aChars )
-        throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
-
     void SAL_CALL setOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream )
         throw (::com::sun::star::uno::RuntimeException);
 
@@ -114,6 +110,9 @@ public:
     void SAL_CALL writeId( ::sal_Int32 Element );
     OString SAL_CALL getId( ::sal_Int32 Element );
 
+    void write( const OUString& s );
+    void write( const OString& s );
+
     static OUString escapeXml( const OUString& s );
 
 public:
@@ -216,7 +215,6 @@ private:
 #endif
 
     void writeFastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs );
-    void write( const OUString& s );
     void writeOutput( const css::uno::Sequence< ::sal_Int8 >& aData )
         throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException);
 
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index c49c0da..cb2c7f7 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -107,28 +107,34 @@ void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, XFastAttribut
 
 FastSerializerHelper* FastSerializerHelper::write(const char* value)
 {
-    return write(OUString::createFromAscii(value));
+    return write(OString(value));
 }
 
 FastSerializerHelper* FastSerializerHelper::write(const OUString& value)
 {
-    mpSerializer->characters(value);
+    mpSerializer->write(value);
+    return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::write(const OString& value)
+{
+    mpSerializer->write(value);
     return this;
 }
 
 FastSerializerHelper* FastSerializerHelper::write(sal_Int32 value)
 {
-    return write(OUString::number(value));
+    return write(OString::number(value));
 }
 
 FastSerializerHelper* FastSerializerHelper::write(sal_Int64 value)
 {
-    return write(OUString::number(value));
+    return write(OString::number(value));
 }
 
 FastSerializerHelper* FastSerializerHelper::write(double value)
 {
-    return write(OUString::number(value));
+    return write(OString::number(value));
 }
 
 FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
commit e4dffa24d59bcf7cea145551d801731141f36669
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Thu Sep 25 16:34:36 2014 +0200

    FastSerializer: check for valid output stream in one place is enough
    
    Change-Id: Id89fb1f0444331c2858a9795ae81dcdb875d3d2b

diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx
index d85bfef..a6b5afd 100644
--- a/sax/source/tools/fastserializer.cxx
+++ b/sax/source/tools/fastserializer.cxx
@@ -72,9 +72,6 @@ namespace sax_fastparser {
 
     void SAL_CALL FastSaxSerializer::startDocument(  ) throw (SAXException, RuntimeException)
     {
-        assert(mxOutputStream.is()); // cannot do anything without that
-        if (!mxOutputStream.is())
-            return;
         rtl::ByteSequence aXmlHeader((const sal_Int8*) "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", 56);
         writeBytes(toUnoSequence(aXmlHeader));
     }
@@ -112,9 +109,6 @@ namespace sax_fastparser {
 
     void SAL_CALL FastSaxSerializer::endDocument(  ) throw (SAXException, RuntimeException)
     {
-        if (!mxOutputStream.is())
-            return;
-
         maOutputStream.flush();
         mxOutputStream->writeBytes(maOutputData);
     }
@@ -151,9 +145,6 @@ namespace sax_fastparser {
     void SAL_CALL FastSaxSerializer::startFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
         throw (SAXException, RuntimeException)
     {
-        if (!mxOutputStream.is())
-            return;
-
         if ( !maMarkStack.empty() )
             maMarkStack.top()->setCurrentElement( Element );
 
@@ -172,9 +163,6 @@ namespace sax_fastparser {
     void SAL_CALL FastSaxSerializer::endFastElement( ::sal_Int32 Element )
         throw (SAXException, RuntimeException)
     {
-        if (!mxOutputStream.is())
-            return;
-
 #ifdef DBG_UTIL
         assert(!m_DebugStartedElements.empty());
         // Well-formedness constraint: Element Type Match
@@ -192,9 +180,6 @@ namespace sax_fastparser {
     void SAL_CALL FastSaxSerializer::singleFastElement( ::sal_Int32 Element, const Reference< XFastAttributeList >& Attribs )
         throw (SAXException, RuntimeException)
     {
-        if (!mxOutputStream.is())
-            return;
-
         if ( !maMarkStack.empty() )
             maMarkStack.top()->setCurrentElement( Element );
 
@@ -209,9 +194,6 @@ namespace sax_fastparser {
     void SAL_CALL FastSaxSerializer::characters( const OUString& aChars )
         throw (SAXException, RuntimeException)
     {
-        if (!mxOutputStream.is())
-            return;
-
         write( aChars );
     }
 
@@ -219,7 +201,6 @@ namespace sax_fastparser {
         throw (::com::sun::star::uno::RuntimeException)
     {
         mxOutputStream = xOutputStream;
-        assert(mxOutputStream.is()); // cannot do anything without that
     }
 
     void SAL_CALL FastSaxSerializer::setFastTokenHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xFastTokenHandler )
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index c19bd4b..c49c0da 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -35,6 +35,7 @@ FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >&
     mxTokenHandler = css::xml::sax::FastTokenHandler::create(xContext);
 
     mpSerializer->setFastTokenHandler( mxTokenHandler );
+    assert(xOutputStream.is()); // cannot do anything without that
     mpSerializer->setOutputStream( xOutputStream );
     if( bWriteHeader )
         mpSerializer->startDocument();


More information about the Libreoffice-commits mailing list