summaryrefslogtreecommitdiff
path: root/sot/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-08-17 13:19:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-08-27 09:10:04 +0200
commita6ad198d097fb4a503c8d5831d484ff46721134b (patch)
treee82ca01e800c5f50ce8db7bd8eb610790ee13c8d /sot/source
parent03b31a8ad48e3b8a9e54203ff3856702557757b5 (diff)
tdf#158556 use more comphelper::ByteReader
which avoids a ton of temporary uno::Sequence being created Change-Id: I237bb69395f692bb0272ca0daec05b81af828e01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171968 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'sot/source')
-rw-r--r--sot/source/sdstor/ucbstorage.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index a6aa800e2436..51c43bb290e3 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -87,7 +87,7 @@ typedef ::cppu::WeakImplHelper < XInputStream, XSeekable > FileInputStreamWrappe
namespace {
-class FileStreamWrapper_Impl : public FileInputStreamWrapper_Base
+class FileStreamWrapper_Impl : public FileInputStreamWrapper_Base, public comphelper::ByteReader
{
protected:
std::mutex m_aMutex;
@@ -107,6 +107,8 @@ public:
virtual sal_Int32 SAL_CALL available() override;
virtual void SAL_CALL closeInput() override;
+ virtual sal_Int32 readSomeBytes(sal_Int8* aData, sal_Int32 nBytesToRead) override;
+
protected:
void checkConnected();
void checkError();
@@ -164,6 +166,23 @@ sal_Int32 SAL_CALL FileStreamWrapper_Impl::readBytes(Sequence< sal_Int8 >& aData
return nRead;
}
+sal_Int32 FileStreamWrapper_Impl::readSomeBytes(sal_Int8* aData, sal_Int32 nBytesToRead)
+{
+ if ( m_aURL.isEmpty() )
+ return 0;
+
+ checkConnected();
+
+ if (nBytesToRead < 0)
+ throw BufferSizeExceededException(OUString(), getXWeak());
+
+ std::scoped_lock aGuard( m_aMutex );
+
+ sal_uInt32 nRead = m_pSvStream->ReadBytes(static_cast<void*>(aData), nBytesToRead);
+ checkError();
+
+ return nRead;
+}
sal_Int32 SAL_CALL FileStreamWrapper_Impl::readSomeBytes(Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead)
{