[Libreoffice-commits] core.git: include/package package/source

Matúš Kukan matus.kukan at collabora.com
Wed Oct 22 07:03:35 PDT 2014


 include/package/Deflater.hxx       |    4 -
 package/source/zipapi/Deflater.cxx |   77 +++++++------------------------------
 2 files changed, 17 insertions(+), 64 deletions(-)

New commits:
commit 87cb3a7c9609a298980e7384633aa383d69eca34
Author: Matúš Kukan <matus.kukan at collabora.com>
Date:   Wed Oct 22 15:31:16 2014 +0200

    unusedcode: Remove Deflater::setLevel
    
    Which makes bSetParams always false; remove that too, together with nLevel.
    
    Change-Id: I94a4ec14b2b2c498d749ef72c1b6b118bba37076

diff --git a/include/package/Deflater.hxx b/include/package/Deflater.hxx
index ad73f28..bd6d815 100644
--- a/include/package/Deflater.hxx
+++ b/include/package/Deflater.hxx
@@ -35,8 +35,7 @@ protected:
     com::sun::star::uno::Sequence< sal_Int8 > sInBuffer;
     bool                    bFinish;
     bool                    bFinished;
-    bool                    bSetParams;
-    sal_Int32               nLevel, nStrategy;
+    sal_Int32               nStrategy;
     sal_Int64               nOffset, nLength;
     z_stream*               pStream;
 
@@ -47,7 +46,6 @@ public:
     ~Deflater();
     Deflater(sal_Int32 nSetLevel, bool bNowrap);
     void SAL_CALL setInputSegment( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength );
-    void SAL_CALL setLevel( sal_Int32 nNewLevel );
     bool SAL_CALL needsInput(  );
     void SAL_CALL finish(  );
     bool SAL_CALL finished(  ) { return bFinished;}
diff --git a/package/source/zipapi/Deflater.cxx b/package/source/zipapi/Deflater.cxx
index 96d43fc..a76362f 100644
--- a/package/source/zipapi/Deflater.cxx
+++ b/package/source/zipapi/Deflater.cxx
@@ -59,8 +59,6 @@ void Deflater::init (sal_Int32 nLevelArg, sal_Int32 nStrategyArg, bool bNowrap)
 Deflater::Deflater(sal_Int32 nSetLevel, bool bNowrap)
 : bFinish(false)
 , bFinished(false)
-, bSetParams(false)
-, nLevel(nSetLevel)
 , nStrategy(DEFAULT_STRATEGY)
 , nOffset(0)
 , nLength(0)
@@ -71,58 +69,26 @@ Deflater::Deflater(sal_Int32 nSetLevel, bool bNowrap)
 sal_Int32 Deflater::doDeflateBytes (uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength)
 {
     sal_Int32 nResult;
-    if (bSetParams)
-    {
-        pStream->next_in   = (unsigned char*) sInBuffer.getConstArray() + nOffset;
-        pStream->next_out  = (unsigned char*) rBuffer.getArray()+nNewOffset;
-        pStream->avail_in  = nLength;
-        pStream->avail_out = nNewLength;
+    pStream->next_in   = (unsigned char*) sInBuffer.getConstArray() + nOffset;
+    pStream->next_out  = (unsigned char*) rBuffer.getArray()+nNewOffset;
+    pStream->avail_in  = nLength;
+    pStream->avail_out = nNewLength;
 
 #if !defined Z_PREFIX
-        nResult = deflateParams(pStream, nLevel, nStrategy);
+    nResult = deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH);
 #else
-        nResult = z_deflateParams(pStream, nLevel, nStrategy);
+    nResult = z_deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH);
 #endif
-        switch (nResult)
-        {
-            case Z_OK:
-                bSetParams = false;
-                nOffset += nLength - pStream->avail_in;
-                nLength = pStream->avail_in;
-                return nNewLength - pStream->avail_out;
-            case Z_BUF_ERROR:
-                bSetParams = false;
-                return 0;
-            default:
-                return 0;
-        }
-    }
-    else
+    switch (nResult)
     {
-        pStream->next_in   = (unsigned char*) sInBuffer.getConstArray() + nOffset;
-        pStream->next_out  = (unsigned char*) rBuffer.getArray()+nNewOffset;
-        pStream->avail_in  = nLength;
-        pStream->avail_out = nNewLength;
-
-#if !defined Z_PREFIX
-        nResult = deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH);
-#else
-        nResult = z_deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH);
-#endif
-        switch (nResult)
-        {
-            case Z_STREAM_END:
-                bFinished = true;
-            case Z_OK:
-                nOffset += nLength - pStream->avail_in;
-                nLength = pStream->avail_in;
-                return nNewLength - pStream->avail_out;
-            case Z_BUF_ERROR:
-                bSetParams = false;
-                return 0;
-            default:
-                return 0;
-        }
+        case Z_STREAM_END:
+            bFinished = true;
+        case Z_OK:
+            nOffset += nLength - pStream->avail_in;
+            nLength = pStream->avail_in;
+            return nNewLength - pStream->avail_out;
+        default:
+            return 0;
     }
 }
 
@@ -134,18 +100,7 @@ void SAL_CALL Deflater::setInputSegment( const uno::Sequence< sal_Int8 >& rBuffe
     nOffset = nNewOffset;
     nLength = nNewLength;
 }
-void SAL_CALL Deflater::setLevel( sal_Int32 nNewLevel )
-{
-    if ((nNewLevel < 0 || nNewLevel > 9) && nNewLevel != DEFAULT_COMPRESSION)
-    {
-        // do error handling
-    }
-    if (nNewLevel != nLevel)
-    {
-        nLevel = nNewLevel;
-        bSetParams = true;
-    }
-}
+
 bool SAL_CALL Deflater::needsInput(  )
 {
     return nLength <=0;


More information about the Libreoffice-commits mailing list