Kaydet (Commit) ee22409a authored tarafından Luboš Luňák's avatar Luboš Luňák

try harder not to deflate small streams in a thread

E.g. with the bugdoc from tdf#93553, most of the streams to save
are actually small, they just do not provide XSeekable. Since it
seems all the streams are already fully available by the time
the zip packaging is done, fallback to XInputStream::available()
to find out if the stream is small.
With this, the zipping part of saving tdf#93553 is now down
from ~1.5s to ~0.5s.
This presumably also makes the hack for tdf#93553 unnecessary.

Change-Id: Id9bb7d835400d6d8f147f5c11ade684a549aba53
Reviewed-on: https://gerrit.libreoffice.org/73030
Tested-by: Jenkins
Reviewed-by: 's avatarLuboš Luňák <l.lunak@collabora.com>
üst e43f0657
......@@ -524,7 +524,7 @@ bool ZipFile::hasValidPassword ( ZipEntry const & rEntry, const ::rtl::Reference
namespace {
class XBufferedStream : public cppu::WeakImplHelper<css::io::XInputStream>
class XBufferedStream : public cppu::WeakImplHelper<css::io::XInputStream, css::io::XSeekable>
{
std::vector<sal_Int8> maBytes;
size_t mnPos;
......@@ -613,6 +613,21 @@ public:
virtual void SAL_CALL closeInput() override
{
}
// XSeekable
virtual void SAL_CALL seek( sal_Int64 location ) override
{
if ( location > sal_Int64(maBytes.size()) || location < 0 )
throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 1 );
mnPos = location;
}
virtual sal_Int64 SAL_CALL getPosition() override
{
return mnPos;
}
virtual sal_Int64 SAL_CALL getLength() override
{
return maBytes.size();
}
};
}
......
......@@ -820,9 +820,13 @@ bool ZipPackageStream::saveChild(
{
// tdf#89236 Encrypting in parallel does not work
bParallelDeflate = !bToBeEncrypted;
// Do not deflate small streams in a thread
// Do not deflate small streams in a thread. XSeekable's getLength()
// gives the full size, XInputStream's available() may not be
// the full size, but it appears that at this point it usually is.
if (xSeek.is() && xSeek->getLength() < 100000)
bParallelDeflate = false;
else if (xStream->available() < 100000)
bParallelDeflate = false;
if (bParallelDeflate)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment