io/source/stm/omark.cxx |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

New commits:
commit 5bb826373f766a0ec105406a98d5529e2c360e8c
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Sep 10 19:17:43 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Sep 11 21:47:48 2022 +0200

    no need to allocate MemRingBuffer separately in OMarkableOutputStream
    
    Change-Id: I80d64f18480a2c078caeaa161f55767f66021253
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139781
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx
index 3991e2c9d966..d4bf6c74169a 100644
--- a/io/source/stm/omark.cxx
+++ b/io/source/stm/omark.cxx
@@ -115,7 +115,7 @@ private:
     Reference< XOutputStream >  m_output;
     bool m_bValidStream;
 
-    std::unique_ptr<MemRingBuffer> m_pBuffer;
+    MemRingBuffer m_aRingBuffer;
     map<sal_Int32,sal_Int32,less< sal_Int32 > > m_mapMarks;
     sal_Int32 m_nCurrentPos;
     sal_Int32 m_nCurrentMark;
@@ -127,7 +127,6 @@ private:
 
 OMarkableOutputStream::OMarkableOutputStream( )
     : m_bValidStream(false)
-    , m_pBuffer( new MemRingBuffer )
     , m_nCurrentPos(0)
     , m_nCurrentMark(0)
 {
@@ -139,14 +138,14 @@ void OMarkableOutputStream::writeBytes(const Sequence< 
sal_Int8 >& aData)
     if( !m_bValidStream ) {
         throw NotConnectedException();
     }
-    if( m_mapMarks.empty() && ( m_pBuffer->getSize() == 0 ) ) {
+    if( m_mapMarks.empty() && ( m_aRingBuffer.getSize() == 0 ) ) {
         // no mark and  buffer active, simple write through
         m_output->writeBytes( aData );
     }
     else {
         std::unique_lock guard( m_mutex );
         // new data must be buffered
-        m_pBuffer->writeAt( m_nCurrentPos , aData );
+        m_aRingBuffer.writeAt( m_nCurrentPos , aData );
         m_nCurrentPos += aData.getLength();
         checkMarksAndFlush();
     }
@@ -179,7 +178,7 @@ void OMarkableOutputStream::closeOutput()
     // all marks must be cleared and all
 
     m_mapMarks.clear();
-    m_nCurrentPos = m_pBuffer->getSize();
+    m_nCurrentPos = m_aRingBuffer.getSize();
     checkMarksAndFlush();
 
     m_output->closeOutput();
@@ -232,7 +231,7 @@ void OMarkableOutputStream::jumpToMark(sal_Int32 nMark)
 void OMarkableOutputStream::jumpToFurthest()
 {
     std::unique_lock guard( m_mutex );
-    m_nCurrentPos = m_pBuffer->getSize();
+    m_nCurrentPos = m_aRingBuffer.getSize();
     checkMarksAndFlush();
 }
 
@@ -328,8 +327,8 @@ void OMarkableOutputStream::checkMarksAndFlush()
         }
 
         Sequence<sal_Int8> seq(nNextFound);
-        m_pBuffer->readAt( 0 , seq , nNextFound );
-        m_pBuffer->forgetFromStart( nNextFound );
+        m_aRingBuffer.readAt( 0 , seq , nNextFound );
+        m_aRingBuffer.forgetFromStart( nNextFound );
 
         // now write data through to streams
         m_output->writeBytes( seq );

Reply via email to