diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-28 00:09:16 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-23 11:53:18 +0200 |
commit | 406062334a4891094928149711fcbb98fccc3fff (patch) | |
tree | dc5d868fe6a21ea5518bd7390191f5b93d290032 | |
parent | 50d2ffd2a107ae8fd5c3e53f4f75234ad37081ea (diff) |
FastSerializer: avoid some more OStrings
Change-Id: I2d5dbe9adccdd231cc16a1f83a90a4adeb965c64
-rw-r--r-- | include/sax/fastattribs.hxx | 4 | ||||
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 6 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 14 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.hxx | 1 | ||||
-rw-r--r-- | sax/source/tools/fshelper.cxx | 5 |
5 files changed, 15 insertions, 15 deletions
diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx index 525548105cbd..85a1218e8616 100644 --- a/include/sax/fastattribs.hxx +++ b/include/sax/fastattribs.hxx @@ -87,6 +87,7 @@ public: void addUnknown( const OString& rName, const sal_Char* pValue ); const std::vector< sal_Int32 >& getFastAttributeTokens() const { return maAttributeTokens; } const char* getFastAttributeValue(size_t nIndex) const { return mpChunk + maAttributeValues[nIndex]; } + sal_Int32 AttributeValueLength(size_t i) const { return maAttributeValues[i + 1] - maAttributeValues[i] - 1; } // performance sensitive shortcuts to avoid allocation ... bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt); @@ -103,9 +104,6 @@ public: virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::FastAttribute > SAL_CALL getFastAttributes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - inline sal_Int32 AttributeValueLength(sal_Int32 i); - -private: sal_Char *mpChunk; ///< buffer to store all attribute values - null terminated strings sal_Int32 mnChunkLength; ///< size of allocated memory for mpChunk // maAttributeValues stores pointers, relative to mpChunk, for each attribute value string 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; } |