summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-06-03 10:00:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-06-03 12:14:41 +0200
commit1439a09a13516f72baa735e5af332b0647d0cff7 (patch)
tree1454f823c3895a88ccd463b2572617dbf9ab6a80 /ucb
parent34bbf192a7753205bb64d14e4eec4ce303317396 (diff)
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@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/file/filstr.cxx8
1 files changed, 4 insertions, 4 deletions
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);
}