[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - 2 commits - include/sfx2 sfx2/source ucb/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 4 07:35:16 UTC 2019


 include/sfx2/docfile.hxx       |    6 +++---
 sfx2/source/doc/docfile.cxx    |   14 +++++++-------
 ucb/source/ucp/file/filstr.cxx |    8 ++++----
 3 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit 77219c88ac0a44b3ed5dada67d0d9ca52fa3adec
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jun 3 10:03:34 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jun 4 09:35:00 2019 +0200

    tdf#67538 XTypeDetection::queryTypeByDescriptor poor performance, part2
    
    SfxMedium was creating a temporary file and copying the input file, when
    CloseInStream_Impl was called from the destructor. Very very bad for
    performance.
    
    This is specifically fixing the performance of queryTypeByDescriptor
    when called from a basic macro on a local test file.
    
    This takes my test macro from 16.1s to 9s.
    
    Change-Id: If52f8e0587c7b11666893f6cb79b3180d45cce43
    Reviewed-on: https://gerrit.libreoffice.org/73375
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit c0d372d7c0d9284aad8b0d5142dff7c34c062fa9)
    Reviewed-on: https://gerrit.libreoffice.org/73399

diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index a8fae8409bb9..77950a473197 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -60,9 +60,9 @@ class SFX2_DLLPUBLIC SfxMedium : public SvRefBase
     std::unique_ptr< SfxMedium_Impl > pImpl;
 
     SAL_DLLPRIVATE void SetIsRemote_Impl();
-    SAL_DLLPRIVATE void CloseInStream_Impl();
+    SAL_DLLPRIVATE void CloseInStream_Impl(bool bInDestruction = false);
     SAL_DLLPRIVATE void CloseOutStream_Impl();
-    SAL_DLLPRIVATE void CloseStreams_Impl();
+    SAL_DLLPRIVATE void CloseStreams_Impl(bool bInDestruction = false);
 
     SAL_DLLPRIVATE void SetEncryptionDataToStorage_Impl();
 
@@ -121,7 +121,7 @@ public:
     const OUString&     GetOrigURL() const;
 
     SfxItemSet  *       GetItemSet() const;
-    void                Close();
+    void                Close(bool bInDestruction = false);
     void                CloseAndRelease();
     void                ReOpen();
     void                CompleteReOpen();
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 177104414099..265fd4edd5b4 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -593,7 +593,7 @@ void SfxMedium::CloseInStream()
     CloseInStream_Impl();
 }
 
-void SfxMedium::CloseInStream_Impl()
+void SfxMedium::CloseInStream_Impl(bool bInDestruction)
 {
     // if there is a storage based on the InStream, we have to
     // close the storage, too, because otherwise the storage
@@ -604,7 +604,7 @@ void SfxMedium::CloseInStream_Impl()
             CloseStorage();
     }
 
-    if ( pImpl->m_pInStream && !GetContent().is() )
+    if ( pImpl->m_pInStream && !GetContent().is() && !bInDestruction )
     {
         CreateTempFile();
         return;
@@ -2905,14 +2905,14 @@ sal_uInt32 SfxMedium::CreatePasswordToModifyHash( const OUString& aPasswd, bool
 }
 
 
-void SfxMedium::Close()
+void SfxMedium::Close(bool bInDestruction)
 {
     if ( pImpl->xStorage.is() )
     {
         CloseStorage();
     }
 
-    CloseStreams_Impl();
+    CloseStreams_Impl(bInDestruction);
 
     UnlockFile( false );
 }
@@ -3081,9 +3081,9 @@ void SfxMedium::CloseAndReleaseStreams_Impl()
 }
 
 
-void SfxMedium::CloseStreams_Impl()
+void SfxMedium::CloseStreams_Impl(bool bInDestruction)
 {
-    CloseInStream_Impl();
+    CloseInStream_Impl(bInDestruction);
     CloseOutStream_Impl();
 
     if ( pImpl->m_pSet )
@@ -3326,7 +3326,7 @@ SfxMedium::~SfxMedium()
     // if there is a requirement to clean the backup this is the last possibility to do it
     ClearBackup_Impl();
 
-    Close();
+    Close(/*bInDestruction*/true);
 
     if( !pImpl->bIsTemp || pImpl->m_aName.isEmpty() )
         return;
commit 6fdd1dc34f497fce28f85807126e56432a3cb7d2
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jun 3 10:00:58 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jun 4 09:34:44 2019 +0200

    tdf#67538 XTypeDetection::queryTypeByDescriptor poor performance, part1
    
    Skip creating an intermediary buffer in XStream_impl::readBytes, and
    just read directly into the destination.
    
    This is specifically fixing the performance of queryTypeByDescriptor
    when called from a basic macro on a local test file.
    
    This takes my test macro from 17.1s to 16.1s.
    
    Change-Id: Iaa7d38c6a90a3b3f01a4b748c4512dd8fda690c7
    Reviewed-on: https://gerrit.libreoffice.org/73374
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit 1439a09a13516f72baa735e5af332b0647d0cff7)
    Reviewed-on: https://gerrit.libreoffice.org/73398

diff --git a/ucb/source/ucp/file/filstr.cxx b/ucb/source/ucp/file/filstr.cxx
index a2419042de45..8b23813abdc4 100644
--- a/ucb/source/ucp/file/filstr.cxx
+++ b/ucb/source/ucp/file/filstr.cxx
@@ -130,10 +130,9 @@ XStream_impl::readBytes(
     if( ! m_nIsOpen )
         throw io::IOException( THROW_WHERE );
 
-    std::unique_ptr<sal_Int8[]> buffer;
     try
     {
-        buffer.reset(new sal_Int8[nBytesToRead]);
+        aData.realloc(nBytesToRead);
     }
     catch (const std::bad_alloc&)
     {
@@ -142,12 +141,13 @@ XStream_impl::readBytes(
     }
 
     sal_uInt64 nrc(0);
-    if(m_aFile.read( buffer.get(),sal_uInt64(nBytesToRead),nrc )
+    if(m_aFile.read( aData.getArray(), sal_uInt64(nBytesToRead), nrc )
        != osl::FileBase::E_None)
     {
         throw io::IOException( THROW_WHERE );
     }
-    aData = uno::Sequence< sal_Int8 > ( buffer.get(), static_cast<sal_uInt32>(nrc) );
+    if (nrc != static_cast<sal_uInt64>(nBytesToRead))
+        aData.realloc(nrc);
     return static_cast<sal_Int32>(nrc);
 }
 


More information about the Libreoffice-commits mailing list