[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 3 10:49:44 UTC 2019


 include/sfx2/docfile.hxx    |    6 +++---
 sfx2/source/doc/docfile.cxx |   14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)

New commits:
commit c0d372d7c0d9284aad8b0d5142dff7c34c062fa9
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: Mon Jun 3 12:48:43 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>

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;


More information about the Libreoffice-commits mailing list