[Libreoffice-commits] core.git: include/tools tools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Nov 9 17:37:43 UTC 2018
include/tools/stream.hxx | 3 ---
tools/source/stream/stream.cxx | 28 ++++++++--------------------
2 files changed, 8 insertions(+), 23 deletions(-)
New commits:
commit 4e6b448b998e3589baa2de46fb2135f1162695ed
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Nov 9 08:45:45 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Nov 9 18:35:42 2018 +0100
SvStream::m_isConsistent is always true
ever since
commit a3b0ee88be3c6bff94ec6fe908f209c1dbb9748d
Date: Sun Jul 10 22:17:35 2011 +0100
strip out unused methods
found by loplugin:singlevalfields
Change-Id: I4feab1195f78549a48f4b1a9017bc5101474228f
Reviewed-on: https://gerrit.libreoffice.org/63173
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index c627ed494998..370372aba454 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -156,9 +156,6 @@ private:
// Error codes, conversion, compression, ...
bool m_isDirty; ///< true: Stream != buffer content
- bool m_isConsistent; ///< false: Buffer contains data, which were
- ///< NOT allowed to be written by PutData
- ///< into the derived stream (cf. PutBack)
bool m_isSwap;
bool m_isEof;
ErrCode m_nError;
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 8fe25c28d055..ea9f533b3af3 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -329,7 +329,6 @@ SvStream::SvStream() :
, m_isIoWrite(false)
, m_isDirty(false)
- , m_isConsistent(true)
, m_isEof(false)
, m_nCompressMode(SvStreamCompressFlags::NONE)
@@ -402,7 +401,7 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
sal_uInt64 const nActualFilePos = Tell();
bool bDontSeek = (m_pRWBuf == nullptr);
- if (m_isDirty && m_isConsistent && m_isWritable) // due to Windows NT: Access denied
+ if (m_isDirty && m_isWritable) // due to Windows NT: Access denied
Flush();
if (m_nBufSize)
@@ -417,7 +416,6 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
m_nBufSize = nBufferSize;
if (m_nBufSize)
m_pRWBuf.reset(new sal_uInt8[ m_nBufSize ]);
- m_isConsistent = true;
m_pBufPos = m_pRWBuf.get();
m_isIoRead = m_isIoWrite = false;
if( !bDontSeek )
@@ -431,7 +429,6 @@ void SvStream::ClearBuffer()
m_nBufFilePos = 0;
m_pBufPos = m_pRWBuf.get();
m_isDirty = false;
- m_isConsistent = true;
m_isIoRead = m_isIoWrite = false;
m_isEof = false;
@@ -893,8 +890,7 @@ SvStream& SvStream::ReadInt64(sal_Int64& r)
SvStream& SvStream::ReadSChar( signed char& r )
{
- if ((m_isIoRead || !m_isConsistent) &&
- sizeof(signed char) <= m_nBufFree)
+ if (m_isIoRead && sizeof(signed char) <= m_nBufFree)
{
r = *m_pBufPos;
m_nBufActualPos += sizeof(signed char);
@@ -910,8 +906,7 @@ SvStream& SvStream::ReadSChar( signed char& r )
SvStream& SvStream::ReadChar( char& r )
{
- if ((m_isIoRead || !m_isConsistent) &&
- sizeof(char) <= m_nBufFree)
+ if (m_isIoRead && sizeof(char) <= m_nBufFree)
{
r = *m_pBufPos;
m_nBufActualPos += sizeof(char);
@@ -925,8 +920,7 @@ SvStream& SvStream::ReadChar( char& r )
SvStream& SvStream::ReadUChar( unsigned char& r )
{
- if ((m_isIoRead || !m_isConsistent) &&
- sizeof(char) <= m_nBufFree)
+ if (m_isIoRead && sizeof(char) <= m_nBufFree)
{
r = *m_pBufPos;
m_nBufActualPos += sizeof(char);
@@ -953,8 +947,7 @@ SvStream& SvStream::ReadUtf16(sal_Unicode& r)
SvStream& SvStream::ReadCharAsBool( bool& r )
{
- if ((m_isIoRead || !m_isConsistent) &&
- sizeof(char) <= m_nBufFree)
+ if (m_isIoRead && sizeof(char) <= m_nBufFree)
{
SAL_WARN_IF(
*m_pBufPos > 1, "tools.stream", unsigned(*m_pBufPos) << " not 0/1");
@@ -1234,8 +1227,6 @@ void SvStream::FlushBuffer(bool isConsistent)
std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
{
std::size_t nSaveCount = nCount;
- if (!m_isConsistent)
- RefreshBuffer();
if (!m_pRWBuf)
{
@@ -1321,8 +1312,6 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount )
SetError( ERRCODE_IO_CANTWRITE );
return 0;
}
- if (!m_isConsistent)
- RefreshBuffer(); // Remove changes in buffer through PutBack
if (!m_pRWBuf)
{
@@ -1404,7 +1393,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
}
else
{
- FlushBuffer(m_isConsistent);
+ FlushBuffer(true);
m_nBufActualLen = 0;
m_nBufActualPos = 0;
m_pBufPos = m_pRWBuf.get();
@@ -1442,21 +1431,20 @@ sal_uInt64 SvStream::TellEnd()
void SvStream::Flush()
{
- FlushBuffer(m_isConsistent);
+ FlushBuffer(true);
if (m_isWritable)
FlushData();
}
void SvStream::RefreshBuffer()
{
- FlushBuffer(m_isConsistent);
+ FlushBuffer(true);
SeekPos(m_nBufFilePos);
m_nBufActualLen = static_cast<sal_uInt16>(GetData( m_pRWBuf.get(), m_nBufSize ));
if (m_nBufActualLen && m_nError == ERRCODE_IO_PENDING)
m_nError = ERRCODE_NONE;
if (m_nCryptMask)
EncryptBuffer(m_pRWBuf.get(), static_cast<std::size_t>(m_nBufActualLen));
- m_isConsistent = true;
m_isIoRead = m_isIoWrite = false;
}
More information about the Libreoffice-commits
mailing list