From 406062334a4891094928149711fcbb98fccc3fff Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Sun, 28 Sep 2014 00:09:16 +0200 Subject: FastSerializer: avoid some more OStrings Change-Id: I2d5dbe9adccdd231cc16a1f83a90a4adeb965c64 --- sax/source/tools/fastattribs.cxx | 6 ------ sax/source/tools/fastserializer.cxx | 14 ++++++++++---- sax/source/tools/fastserializer.hxx | 1 + sax/source/tools/fshelper.cxx | 5 +++-- 4 files changed, 14 insertions(+), 12 deletions(-) (limited to 'sax') diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index 67f3196b12c9..e2cbcc677238 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -225,12 +225,6 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes( ) throw (Runtim return aSeq; } -sal_Int32 FastAttributeList::AttributeValueLength(sal_Int32 i) -{ - // Pointers to null terminated strings - return maAttributeValues[i + 1] - maAttributeValues[i] - 1; -} - sal_Int32 FastTokenHandlerBase::getTokenFromChars( const css::uno::Reference< css::xml::sax::XFastTokenHandler > &xTokenHandler, FastTokenHandlerBase *pTokenHandler, diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 3a8b770c182c..d6c1a949b3dc 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -83,14 +83,20 @@ namespace sax_fastparser { void FastSaxSerializer::write( const OString& sOutput, bool bEscape ) { + write( sOutput.getStr(), sOutput.getLength(), bEscape ); + } + + void FastSaxSerializer::write( const char* pStr, sal_Int32 nLen, bool bEscape ) + { + if (nLen == 0) + nLen = strlen(pStr); + if (!bEscape) { - writeBytes( sOutput.getStr(), sOutput.getLength() ); + writeBytes( pStr, nLen ); return; } - const char* pStr = sOutput.getStr(); - sal_Int32 nLen = sOutput.getLength(); for (sal_Int32 i = 0; i < nLen; ++i) { char c = pStr[ i ]; @@ -222,7 +228,7 @@ namespace sax_fastparser { writeBytes(sEqualSignAndQuote, N_CHARS(sEqualSignAndQuote)); - write(pAttrList->getFastAttributeValue(j), true); + write(pAttrList->getFastAttributeValue(j), pAttrList->AttributeValueLength(j), true); writeBytes(sQuote, N_CHARS(sQuote)); } diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx index 089348a004e9..05db2c792354 100644 --- a/sax/source/tools/fastserializer.hxx +++ b/sax/source/tools/fastserializer.hxx @@ -105,6 +105,7 @@ public: void write( const OUString& s, bool bEscape = false ); void write( const OString& s, bool bEscape = false ); + void write( const char* pStr, sal_Int32 nLen, bool bEscape = false ); public: /** From now on, don't write directly to the stream, but to top of a stack. diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index 30e59322f034..c6ac390dca19 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -109,7 +109,8 @@ void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, XFastAttribut FastSerializerHelper* FastSerializerHelper::write(const char* value) { - return write(OString(value)); + mpSerializer->write(value, 0, false); + return this; } FastSerializerHelper* FastSerializerHelper::write(const OUString& value) @@ -141,7 +142,7 @@ FastSerializerHelper* FastSerializerHelper::write(double value) FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value) { - mpSerializer->write(OString(value), true); + mpSerializer->write(value, 0, true); return this; } -- cgit