[Libreoffice-commits] core.git: Branch 'feature/perfwork4' - 2 commits - package/source
Matúš Kukan
matus.kukan at collabora.com
Fri Oct 24 05:48:43 PDT 2014
package/source/zippackage/ZipPackageStream.cxx | 45 +++++++++++++++++--------
1 file changed, 31 insertions(+), 14 deletions(-)
New commits:
commit 63822b409d5f4556759afd1d30125521a958f28c
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Fri Oct 24 14:46:21 2014 +0200
Disable deflating in a thread
Change-Id: I1803cd61e283bcc20d4d59870121e785bc778f4a
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 41c76c5..774e8af 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -798,7 +798,7 @@ bool ZipPackageStream::saveChild(
}
else
{
- bParallelDeflate = true;
+ bParallelDeflate = false;
if (bParallelDeflate)
{
// Start a new thread deflating this zip entry
commit 758d17dd59d1928bde6e9dc0b98322c7d493f5b8
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Fri Oct 24 14:43:06 2014 +0200
package: Add possibility to disable deflating in a thread
Change-Id: I4d98b6f8b3315b731206700eb65f08463299dda3
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index ff76105..41c76c5 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -439,6 +439,20 @@ bool ZipPackageStream::ParsePackageRawStream()
return true;
}
+static void deflateZipEntry(ZipOutputEntry *pZipEntry,
+ const uno::Reference< io::XInputStream >& xInStream)
+{
+ sal_Int32 nLength = 0;
+ uno::Sequence< sal_Int8 > aSeq(n_ConstBufferSize);
+ do
+ {
+ nLength = xInStream->readBytes(aSeq, n_ConstBufferSize);
+ pZipEntry->write(aSeq, 0, nLength);
+ }
+ while (nLength == n_ConstBufferSize);
+ pZipEntry->closeEntry();
+}
+
class DeflateThread: public osl::Thread
{
ZipOutputEntry *mpEntry;
@@ -454,16 +468,7 @@ public:
private:
virtual void SAL_CALL run() SAL_OVERRIDE
{
- sal_Int32 nLength = 0;
- uno::Sequence< sal_Int8 > aSeq(n_ConstBufferSize);
- do
- {
- nLength = mxInStream->readBytes(aSeq, n_ConstBufferSize);
- mpEntry->write(aSeq, 0, nLength);
- }
- while (nLength == n_ConstBufferSize);
- mpEntry->closeEntry();
-
+ deflateZipEntry(mpEntry, mxInStream);
mxInStream.clear();
}
};
@@ -794,9 +799,21 @@ bool ZipPackageStream::saveChild(
else
{
bParallelDeflate = true;
- // Start a new thread deflating this zip entry
- ZipOutputEntry *pZipEntry = new ZipOutputEntry(m_xContext, *pTempEntry, this, bToBeEncrypted);
- rZipOut.addDeflatingThread( pZipEntry, new DeflateThread(pZipEntry, xStream) );
+ if (bParallelDeflate)
+ {
+ // Start a new thread deflating this zip entry
+ ZipOutputEntry *pZipEntry = new ZipOutputEntry(m_xContext, *pTempEntry, this, bToBeEncrypted);
+ rZipOut.addDeflatingThread( pZipEntry, new DeflateThread(pZipEntry, xStream) );
+ }
+ else
+ {
+ rZipOut.writeLOC(pTempEntry, bToBeEncrypted);
+ ZipOutputEntry aZipEntry(m_xContext, *pTempEntry, this, bToBeEncrypted);
+ deflateZipEntry(&aZipEntry, xStream);
+ uno::Sequence< sal_Int8 > aCompressedData = aZipEntry.getData();
+ rZipOut.rawWrite(aCompressedData, 0, aCompressedData.getLength());
+ rZipOut.rawCloseEntry(bToBeEncrypted);
+ }
}
}
catch ( ZipException& )
More information about the Libreoffice-commits
mailing list