diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-18 11:48:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-18 15:15:21 +0200 |
commit | 5a4d78d9a9b45c7fa387b66f5e310447ec813034 (patch) | |
tree | 82e64c853460ae0eb54fd65adb62761e9771d5b6 /include/comphelper | |
parent | 800f9233513a45aa8f8950cf929fd44cb9381d72 (diff) |
tdf#63130 reduce large memory copies when reading from BinaryDataContainer
rather than writing a bunch more code, extract the common part from
comphelper::SequenceInputStream into a new base class
Change-Id: I0d3561e3ca2e748b904128e3b5955e27196d7170
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151943
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/comphelper')
-rw-r--r-- | include/comphelper/seqstream.hxx | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/include/comphelper/seqstream.hxx b/include/comphelper/seqstream.hxx index 1f1db113116a..1fd695bddf0d 100644 --- a/include/comphelper/seqstream.hxx +++ b/include/comphelper/seqstream.hxx @@ -33,21 +33,18 @@ namespace comphelper { - -// SequenceInputStream -// stream for reading data from a sequence of bytes - - -class COMPHELPER_DLLPUBLIC SequenceInputStream final +/** Base class for wrappers around memory data that want to be exposed as an XInputStream */ +class COMPHELPER_DLLPUBLIC MemoryInputStream : public ::cppu::WeakImplHelper< css::io::XInputStream, css::io::XSeekable >, public comphelper::ByteReader { std::mutex m_aMutex; - css::uno::Sequence<sal_Int8> const m_aData; + const sal_Int8* m_pMemoryData; + sal_Int32 m_nMemoryDataLength; sal_Int32 m_nPos; public: - SequenceInputStream(css::uno::Sequence<sal_Int8> const & rData); + MemoryInputStream(const sal_Int8* pData, sal_Int32 nDataLength); // css::io::XInputStream virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence<sal_Int8>& aData, sal_Int32 nBytesToRead ) override; @@ -71,6 +68,17 @@ private: sal_Int32 avail(); }; + +// Stream for reading data from a sequence of bytes +class COMPHELPER_DLLPUBLIC SequenceInputStream final + : public MemoryInputStream +{ + css::uno::Sequence<sal_Int8> const m_aData; + +public: + SequenceInputStream(css::uno::Sequence<sal_Int8> const & rData); +}; + // don't export to avoid duplicate WeakImplHelper definitions with MSVC class SAL_DLLPUBLIC_TEMPLATE OSequenceOutputStream_Base : public ::cppu::WeakImplHelper< css::io::XOutputStream > |