diff options
Diffstat (limited to 'io/source/stm')
-rw-r--r-- | io/source/stm/odata.cxx | 50 | ||||
-rw-r--r-- | io/source/stm/streamhelper.cxx | 13 |
2 files changed, 24 insertions, 39 deletions
diff --git a/io/source/stm/odata.cxx b/io/source/stm/odata.cxx index 260280216c11..0c1dd29f9bb1 100644 --- a/io/source/stm/odata.cxx +++ b/io/source/stm/odata.cxx @@ -167,7 +167,7 @@ sal_Int8 ODataInputStream::readByte() { throw UnexpectedEOFException(); } - return aTmp.getArray()[0]; + return aTmp.getConstArray()[0]; } sal_Unicode ODataInputStream::readChar() @@ -522,54 +522,40 @@ void ODataOutputStream::writeBoolean(sal_Bool Value) void ODataOutputStream::writeByte(sal_Int8 Value) { - Sequence<sal_Int8> aTmp( 1 ); - aTmp.getArray()[0] = Value; - writeBytes( aTmp ); + writeBytes( { Value } ); } void ODataOutputStream::writeChar(sal_Unicode Value) { - Sequence<sal_Int8> aTmp( 2 ); - sal_Int8 * pBytes = aTmp.getArray(); - pBytes[0] = sal_Int8(Value >> 8); - pBytes[1] = sal_Int8(Value); - writeBytes( aTmp ); + writeBytes( { sal_Int8(Value >> 8), + sal_Int8(Value) } ); } void ODataOutputStream::writeShort(sal_Int16 Value) { - Sequence<sal_Int8> aTmp( 2 ); - sal_Int8 * pBytes = aTmp.getArray(); - pBytes[0] = sal_Int8(Value >> 8); - pBytes[1] = sal_Int8(Value); - writeBytes( aTmp ); + writeBytes( { sal_Int8(Value >> 8), + sal_Int8(Value) } ); } void ODataOutputStream::writeLong(sal_Int32 Value) { - Sequence<sal_Int8> aTmp( 4 ); - sal_Int8 * pBytes = aTmp.getArray(); - pBytes[0] = sal_Int8(Value >> 24); - pBytes[1] = sal_Int8(Value >> 16); - pBytes[2] = sal_Int8(Value >> 8); - pBytes[3] = sal_Int8(Value); - writeBytes( aTmp ); + writeBytes( { sal_Int8(Value >> 24), + sal_Int8(Value >> 16), + sal_Int8(Value >> 8), + sal_Int8(Value) } ); } void ODataOutputStream::writeHyper(sal_Int64 Value) { - Sequence<sal_Int8> aTmp( 8 ); - sal_Int8 * pBytes = aTmp.getArray(); - pBytes[0] = sal_Int8(Value >> 56); - pBytes[1] = sal_Int8(Value >> 48); - pBytes[2] = sal_Int8(Value >> 40); - pBytes[3] = sal_Int8(Value >> 32); - pBytes[4] = sal_Int8(Value >> 24); - pBytes[5] = sal_Int8(Value >> 16); - pBytes[6] = sal_Int8(Value >> 8); - pBytes[7] = sal_Int8(Value); - writeBytes( aTmp ); + writeBytes( { sal_Int8(Value >> 56), + sal_Int8(Value >> 48), + sal_Int8(Value >> 40), + sal_Int8(Value >> 32), + sal_Int8(Value >> 24), + sal_Int8(Value >> 16), + sal_Int8(Value >> 8), + sal_Int8(Value) } ); } diff --git a/io/source/stm/streamhelper.cxx b/io/source/stm/streamhelper.cxx index 20280b850563..be0644d5e1b2 100644 --- a/io/source/stm/streamhelper.cxx +++ b/io/source/stm/streamhelper.cxx @@ -118,7 +118,7 @@ void MemRingBuffer::readAt( sal_Int32 nPos, Sequence<sal_Int8> &seq , sal_Int32 void MemRingBuffer::writeAt( sal_Int32 nPos, const Sequence<sal_Int8> &seq ) { checkInvariants(); - sal_Int32 nLen = seq.getLength(); + const sal_Int32 nLen = seq.getLength(); if( nPos < 0 || nPos > std::numeric_limits< sal_Int32 >::max() - nLen ) { @@ -127,7 +127,8 @@ void MemRingBuffer::writeAt( sal_Int32 nPos, const Sequence<sal_Int8> &seq ) } if( nPos + nLen - m_nOccupiedBuffer > 0 ) { - resizeBuffer( nPos + seq.getLength() ); + resizeBuffer( nPos + nLen ); + m_nOccupiedBuffer = nPos + nLen; } sal_Int32 nStartWritingIndex = m_nStart + nPos; @@ -135,18 +136,16 @@ void MemRingBuffer::writeAt( sal_Int32 nPos, const Sequence<sal_Int8> &seq ) nStartWritingIndex -= m_nBufferLen; } - if( nLen + nStartWritingIndex > m_nBufferLen ) { + if( const sal_Int32 nBufferRestLen = m_nBufferLen-nStartWritingIndex; nLen > nBufferRestLen ) { // two area copy - memcpy( &(m_p[nStartWritingIndex]) , seq.getConstArray(), m_nBufferLen-nStartWritingIndex ); - memcpy( m_p , &( seq.getConstArray()[m_nBufferLen-nStartWritingIndex] ), - nLen - (m_nBufferLen-nStartWritingIndex) ); + memcpy( &(m_p[nStartWritingIndex]) , seq.getConstArray(), nBufferRestLen ); + memcpy( m_p , &( seq.getConstArray()[nBufferRestLen] ), nLen - nBufferRestLen ); } else { // one area copy memcpy( &( m_p[nStartWritingIndex]), seq.getConstArray() , nLen ); } - m_nOccupiedBuffer = std::max( nPos + seq.getLength() , m_nOccupiedBuffer ); checkInvariants(); } |