diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-03 11:35:46 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-23 14:30:28 +0200 |
commit | 03040ac23be13d8bbcee9f5be3d21979d7705a0e (patch) | |
tree | 9e2798b94dcafa766572f54016c54d6ef3796c1e /sax | |
parent | 25eba216d8b0201bcadb6d4f23484f9ec8f123a2 (diff) |
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
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/tools/CachedOutputStream.hxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sax/source/tools/CachedOutputStream.hxx b/sax/source/tools/CachedOutputStream.hxx index 82c2b6624840..8877bb779a4e 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; } |