diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-10 11:51:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-10 17:59:45 +0100 |
commit | 17950f4d204e9947f125ebc0aac1156eba6501f2 (patch) | |
tree | 1b51bdc13a1006aeb29a6dff658ba1b3f1028708 /tools | |
parent | 952b3b227e02ae4eedce3138fcb39613bf12486d (diff) |
use less SvStream::Flush()
Flush() turns into a sync() on the device, which is pretty slow.
Most of the time all we actually want to do is to flush the internal
buffers from the SvStream.
So expose the FlushBuffer method and use that where possible.
And also means we don't need the mbDontFlushOnClose flag on SvStream
any more.
Change-Id: Ibe089b88b325f0fdc565200a97ce72cd26b7fcfb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128214
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/stream.cxx | 6 | ||||
-rw-r--r-- | tools/source/stream/strmunx.cxx | 5 | ||||
-rw-r--r-- | tools/source/stream/strmwnt.cxx | 5 |
3 files changed, 5 insertions, 11 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 016c8b67e891..a40e13d70b82 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -378,7 +378,7 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize ) bool bDontSeek = (m_pRWBuf == nullptr); if (m_isDirty && m_isWritable) // due to Windows NT: Access denied - Flush(); + FlushBuffer(); if (m_nBufSize) { @@ -1546,7 +1546,7 @@ SvMemoryStream::~SvMemoryStream() if( bOwnsData ) FreeMemory(); else - Flush(); + FlushBuffer(); } } @@ -1754,7 +1754,7 @@ void SvMemoryStream::FreeMemory() void* SvMemoryStream::SwitchBuffer() { - Flush(); + FlushBuffer(); if( !bOwnsData ) return nullptr; Seek( STREAM_SEEK_TO_BEGIN ); diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index 9beade27e92e..d01866476f51 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -198,7 +198,6 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nOpenMode ) { bIsOpen = false; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset(new StreamData); SetBufferSize( 1024 ); @@ -216,7 +215,6 @@ SvFileStream::SvFileStream() { bIsOpen = false; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset(new StreamData); SetBufferSize( 1024 ); } @@ -460,8 +458,7 @@ void SvFileStream::Close() if ( IsOpen() ) { SAL_INFO("tools", "Closing " << aFilename); - if ( !mbDontFlushOnClose ) - Flush(); + FlushBuffer(); osl_closeFile( pInstanceData->rHandle ); pInstanceData->rHandle = nullptr; } diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index c91628b55091..4ea9c7eb1d42 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -107,7 +107,6 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nMode ) bIsOpen = false; nLockCounter = 0; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset( new StreamData ); SetBufferSize( 8192 ); @@ -124,7 +123,6 @@ SvFileStream::SvFileStream() bIsOpen = false; nLockCounter = 0; m_isWritable = false; - mbDontFlushOnClose = false; pInstanceData.reset( new StreamData ); SetBufferSize( 8192 ); @@ -379,8 +377,7 @@ void SvFileStream::Close() nLockCounter = 1; UnlockFile(); } - if ( !mbDontFlushOnClose ) - Flush(); + FlushBuffer(); CloseHandle( pInstanceData->hFile ); } bIsOpen = false; |