[Libreoffice-commits] core.git: Branch 'feature/perfwork5' - package/source

Matúš Kukan matus.kukan at collabora.com
Wed Nov 12 12:44:42 PST 2014


 package/source/zippackage/ZipPackageStream.cxx |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit b5fc498c6f74469c5134cd5fd297ae9ee9772724
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Nov 12 21:25:55 2014 +0100

    package: Do not bother with deflating big jpeg images
    
    It takes a lot of time and we can save 1% of size if at all. Rather
    store them uncompressed in the zip file.
    Maybe we should not deflate jpeg files at all. For some small ones,
    about 100KB - 200KB, I've seen 2% savings.
    With png, we can save a bit more, although it's still only about 4% - 8%.
    
    Change-Id: I43a3e3812882e4ce85e7af9d0aaab454d98c4860

diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 5eaa6e951..157a905 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -772,6 +772,17 @@ bool ZipPackageStream::saveChild(
             pTempEntry->nCrc = -1;
             pTempEntry->nCompressedSize = pTempEntry->nSize = -1;
         }
+        uno::Reference< io::XSeekable > xSeek(xStream, uno::UNO_QUERY);
+        sal_Int32 nStreamLength = 0;
+        if (xSeek.is())
+           nStreamLength = xSeek->getLength();
+
+        // It's not worth to deflate big jpegs to save ~1% in a slow process
+        if (msMediaType.endsWith("/jpeg") && nStreamLength && nStreamLength > 500000)
+        {
+            ImplSetStoredData(*pTempEntry, xStream);
+            xSeek->seek(0);
+        }
 
         try
         {
@@ -799,8 +810,7 @@ bool ZipPackageStream::saveChild(
             {
                 bParallelDeflate = true;
                 // Do not deflate small streams in a thread
-                uno::Reference< io::XSeekable > xSeek( xStream, uno::UNO_QUERY );
-                if (xSeek.is() && xSeek->getLength() < 100000)
+                if (nStreamLength && nStreamLength < 100000)
                     bParallelDeflate = false;
 
                 if (bParallelDeflate)


More information about the Libreoffice-commits mailing list