[Libreoffice-commits] core.git: ucb/source

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


 ucb/source/ucp/file/filstr.cxx |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 1439a09a13516f72baa735e5af332b0647d0cff7
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: Mon Jun 3 12:14:41 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>

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