summaryrefslogtreecommitdiff
path: root/comphelper/source/streaming
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-09-26 17:17:50 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-10-23 11:53:17 +0200
commit20538c25129ebadfa2050c0071887e1e2a46c838 (patch)
tree2183e7b8733bb90359700e638cfc78c9f90ae6ca /comphelper/source/streaming
parent8dc668999a9fea8c6fe8acb84dbe1588f670fd78 (diff)
FastSerializer: Avoid sequences where possible
Change-Id: I359ca9d3b766b71904e4199ebfbdbd5b203775cc
Diffstat (limited to 'comphelper/source/streaming')
-rw-r--r--comphelper/source/streaming/seqstream.cxx23
1 files changed, 14 insertions, 9 deletions
diff --git a/comphelper/source/streaming/seqstream.cxx b/comphelper/source/streaming/seqstream.cxx
index aec451986075..91fdc7d73378 100644
--- a/comphelper/source/streaming/seqstream.cxx
+++ b/comphelper/source/streaming/seqstream.cxx
@@ -156,14 +156,19 @@ OSequenceOutputStream::OSequenceOutputStream(Sequence< sal_Int8 >& _rSeq, double
// this heuristic is as good as any other ... supply better parameters if you don't like it :)
}
-
void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rData ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
{
+ writeBytes(_rData.getConstArray(), _rData.getLength());
+}
+
+void SAL_CALL OSequenceOutputStream::writeBytes( const sal_Int8* pStr, sal_Int32 nLen )
+ throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception)
+{
if (!m_bConnected)
throw NotConnectedException();
// ensure the sequence has enough space left
- if (m_nSize + _rData.getLength() > m_rSequence.getLength())
+ if (m_nSize + nLen > m_rSequence.getLength())
{
sal_Int32 nCurrentLength = m_rSequence.getLength();
sal_Int32 nNewLength = static_cast< sal_Int32 >(
@@ -177,18 +182,18 @@ void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rD
// such a large step is not allowed
nNewLength = nCurrentLength + m_nMaximumResize;
- if (nNewLength < m_nSize + _rData.getLength())
+ if (nNewLength < m_nSize + nLen)
{ // it's not enough .... the data would not fit
// let's take the double amount of the length of the data to be written, as the next write
// request could be as large as this one
- sal_Int32 nNewGrowth = _rData.getLength() * 2;
+ sal_Int32 nNewGrowth = nLen * 2;
if ((m_nMaximumResize > 0) && (nNewGrowth > m_nMaximumResize))
{ // we came to the limit, again ...
nNewGrowth = m_nMaximumResize;
- if (nNewGrowth + nCurrentLength < m_nSize + _rData.getLength())
+ if (nNewGrowth + nCurrentLength < m_nSize + nLen)
// but it would not fit if we respect the limit
- nNewGrowth = m_nSize + _rData.getLength() - nCurrentLength;
+ nNewGrowth = m_nSize + nLen - nCurrentLength;
}
nNewLength = nCurrentLength + nNewGrowth;
}
@@ -199,11 +204,11 @@ void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rD
m_rSequence.realloc(nNewLength);
}
- OSL_ENSURE(m_rSequence.getLength() >= m_nSize + _rData.getLength(),
+ OSL_ENSURE(m_rSequence.getLength() >= m_nSize + nLen,
"ooops ... the realloc algorithm seems to be wrong :( !");
- memcpy(m_rSequence.getArray() + m_nSize, _rData.getConstArray(), _rData.getLength());
- m_nSize += _rData.getLength();
+ memcpy(m_rSequence.getArray() + m_nSize, pStr, nLen);
+ m_nSize += nLen;
}