include/sax/fshelper.hxx | 1 - oox/source/core/xmlfilterbase.cxx | 7 +++---- sax/source/tools/CachedOutputStream.hxx | 14 ++++++++++---- sax/source/tools/fastserializer.cxx | 4 ++-- sax/source/tools/fshelper.cxx | 22 ++++++++++------------ 5 files changed, 25 insertions(+), 23 deletions(-)
New commits: commit 06af390c362f9801b610c87307d31f99cf9afd6c Author: Matúš Kukan <matus.ku...@collabora.com> Date: Fri Oct 3 11:35:46 2014 +0200 FastSerializer: Use fixed sized Sequence directly as cache Well, at least the allocated space is fixed size. When passing that to XOutputStream, change the size in a hacky way. Change-Id: I24fa134286e3086beda25c9a6915549e7c69119a diff --git a/sax/source/tools/CachedOutputStream.hxx b/sax/source/tools/CachedOutputStream.hxx index 82c2b66..8877bb7 100644 --- a/sax/source/tools/CachedOutputStream.hxx +++ b/sax/source/tools/CachedOutputStream.hxx @@ -28,10 +28,14 @@ class CachedOutputStream /// Output stream, usually writing data into files. css::uno::Reference< css::io::XOutputStream > mxOutputStream; sal_Int32 mnCacheWrittenSize; - sal_Int8 mpCache[ mnMaximumSize ]; + const css::uno::Sequence<sal_Int8> mpCache; + uno_Sequence *pSeq; public: - CachedOutputStream() : mnCacheWrittenSize(0) {} + CachedOutputStream() : mnCacheWrittenSize(0) + , mpCache(mnMaximumSize) + , pSeq(mpCache.get()) + {} ~CachedOutputStream() {} css::uno::Reference< css::io::XOutputStream > getOutputStream() const @@ -62,14 +66,16 @@ public: } } - memcpy(mpCache + mnCacheWrittenSize, pStr, nLen); + memcpy(pSeq->elements + mnCacheWrittenSize, pStr, nLen); mnCacheWrittenSize += nLen; } /// immediately write buffer into mxOutputStream and clear void flush() { - mxOutputStream->writeBytes( css::uno::Sequence<sal_Int8>(mpCache, mnCacheWrittenSize) ); + // resize the Sequence to written size + pSeq->nElements = mnCacheWrittenSize; + mxOutputStream->writeBytes( mpCache ); // and next time write to the beginning mnCacheWrittenSize = 0; } commit a83e71c71bdaf1c947545d1d88fcd0814715451d Author: Matúš Kukan <matus.ku...@collabora.com> Date: Fri Oct 3 10:41:18 2014 +0200 FastSerializer: Use -1 for unknown string length Change-Id: I3920caf9d95f20992b7961873f1668468d797e8e diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index d885768..3876609 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -113,7 +113,7 @@ namespace sax_fastparser { void FastSaxSerializer::write( const char* pStr, sal_Int32 nLen, bool bEscape ) { - if (nLen == 0) + if (nLen == -1) nLen = strlen(pStr); if (!bEscape) @@ -251,7 +251,7 @@ namespace sax_fastparser { writeBytes(sEqualSignAndQuote, N_CHARS(sEqualSignAndQuote)); - write(maTokenValues[j].pValue, 0, true); + write(maTokenValues[j].pValue, -1, true); writeBytes(sQuote, N_CHARS(sQuote)); } diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index e0ed751..801be10 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -102,7 +102,7 @@ void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, XFastAttribut FastSerializerHelper* FastSerializerHelper::write(const char* value) { - mpSerializer->write(value, 0, false); + mpSerializer->write(value, -1, false); return this; } @@ -132,13 +132,14 @@ FastSerializerHelper* FastSerializerHelper::write(double value) FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value) { - mpSerializer->write(value, 0, true); + mpSerializer->write(value, -1, true); return this; } FastSerializerHelper* FastSerializerHelper::writeEscaped(const OUString& value) { - mpSerializer->write(value, true); + if (!value.isEmpty()) + mpSerializer->write(value, true); return this; } commit 8e243bb23fbc55dafa048454b827142cedec6faa Author: Matúš Kukan <matus.ku...@collabora.com> Date: Fri Oct 3 11:16:39 2014 +0200 Remove few pointless OUString::number() and one method Change-Id: I3e9a302a7513eebfeff07402f71fc3dde22e4cc2 diff --git a/include/sax/fshelper.hxx b/include/sax/fshelper.hxx index 1f3b1b8..50248ce 100644 --- a/include/sax/fshelper.hxx +++ b/include/sax/fshelper.hxx @@ -124,7 +124,6 @@ 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/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index bf82eef..fb5908f 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -524,7 +524,7 @@ static void writeElement( FSHelperPtr pDoc, sal_Int32 nXmlElement, const sal_Int32 nValue ) { pDoc->startElement( nXmlElement, FSEND ); - pDoc->write( OUString::number( nValue ) ); + pDoc->write( nValue ); pDoc->endElement( nXmlElement ); } @@ -677,7 +677,7 @@ writeAppProperties( XmlFilterBase& rSelf, Reference< XDocumentProperties > xProp { sal_Int32 nValue = 0; if (it->second >>= nValue) - writeElement(pAppProps, XML_Paragraphs, OUString::number(nValue)); + writeElement(pAppProps, XML_Paragraphs, nValue); } uno::Reference<beans::XPropertyAccess> xUserDefinedProperties(xProperties->getUserDefinedProperties(), uno::UNO_QUERY); @@ -715,10 +715,9 @@ writeCustomProperties( XmlFilterBase& rSelf, Reference< XDocumentProperties > xP { OString aName = OUStringToOString( aprop[n].Name, RTL_TEXTENCODING_ASCII_US ); // pid starts from 2 not from 1 as MS supports pid from 2 - OString pid = OUStringToOString( OUString::number(n + 2), RTL_TEXTENCODING_ASCII_US ); pAppProps->startElement( XML_property , XML_fmtid, "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", - XML_pid, pid, + XML_pid, OString::number(n + 2), XML_name, aName, FSEND); diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index 55be646..e0ed751 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -112,25 +112,22 @@ FastSerializerHelper* FastSerializerHelper::write(const OUString& value) return this; } -FastSerializerHelper* FastSerializerHelper::write(const OString& value) -{ - mpSerializer->write(value); - return this; -} - FastSerializerHelper* FastSerializerHelper::write(sal_Int32 value) { - return write(OString::number(value)); + mpSerializer->write(OString::number(value)); + return this; } FastSerializerHelper* FastSerializerHelper::write(sal_Int64 value) { - return write(OString::number(value)); + mpSerializer->write(OString::number(value)); + return this; } FastSerializerHelper* FastSerializerHelper::write(double value) { - return write(OString::number(value)); + mpSerializer->write(OString::number(value)); + return this; } FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits