packages feed

lzlib 1.0.5.0 → 1.0.6.0

raw patch · 3 files changed

+24/−11 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Codec.Lzip: LzOptions :: !Int -> !Int -> LzOptions
+ Codec.Lzip: [dictionarySize] :: LzOptions -> !Int
+ Codec.Lzip: [matchLenLimit] :: LzOptions -> !Int
+ Codec.Lzip: compressFineTune :: LzOptions -> ByteString -> Int -> ByteString
+ Codec.Lzip: data LzOptions

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # lzlib +## 1.0.6.0++  * Export `compressFineTune`+ ## 1.0.5.0    * Export `LZError`
lzlib.cabal view
@@ -1,6 +1,6 @@ cabal-version:      1.18 name:               lzlib-version:            1.0.5.0+version:            1.0.6.0 license:            BSD3 license-file:       LICENSE copyright:          Copyright: (c) 2019-2020 Vanessa McHale
src/Codec/Lzip.hs view
@@ -16,7 +16,11 @@                   , compressFileLevel                   , compressFileBest                   , compressFileFast+                  , compressFineTune                   , CompressionLevel (..)+                  , LzOptions (..)+                  -- * Decompression+                  , decompress                   , LZErrno                     ( LzMemError                     , LzHeaderError@@ -24,8 +28,6 @@                     , LzDataError                     , LzLibraryError                     )-                  -- * Decompression-                  , decompress                   -- * Miscellany                   , lZVersion                   , lZApiVersion@@ -65,8 +67,8 @@     deriving (Enum)  data LzOptions = LzOptions-    { _dictionarySize :: !Int-    , _matchLenLimit  :: !Int+    { dictionarySize :: !Int+    , matchLenLimit  :: !Int     }  encoderOptions :: CompressionLevel -> LzOptions@@ -186,7 +188,9 @@ compressFast :: BSL.ByteString -> BSL.ByteString compressFast = compressWith Zero --- | @since 1.0.0.0+-- | Use this to avoid forcing the whole file into memory at once+--+-- @since 1.0.0.0 compressFile :: FilePath -> IO BSL.ByteString compressFile = compressFileLevel Six @@ -216,14 +220,20 @@                -> BSL.ByteString                -> Int -- ^ Size of data being compressed, in bytes.                -> BSL.ByteString-compressWithSz level bstr sz = runST $ do+compressWithSz cl = compressFineTune (encoderOptions cl) +compressFineTune :: LzOptions+                 -> BSL.ByteString+                 -> Int -- ^ Size of data being compressed, in bytes.+                 -> BSL.ByteString+compressFineTune opts bstr sz = runST $ do+     let bss = BSL.toChunks bstr         delta = sz `div` 4 + 64      (buf, enc) <- LazyST.unsafeIOToST $ do         buf <- mallocForeignPtrBytes delta-        encoder <- lZCompressOpen (fromIntegral $ dictionarySize sz) (fromIntegral matchLenLimit) (fromIntegral memberSize)+        encoder <- lZCompressOpen (fromIntegral $ dictionarySize' sz) (fromIntegral matchLenLimit') (fromIntegral memberSize)         enc <- newForeignPtr lZCompressClose (castPtr encoder)         pure (buf, enc) @@ -273,6 +283,5 @@         memberSize = maxBound          -- saves memory-        dictionarySize = max (fromIntegral lZMinDictionarySize) . min (_dictionarySize $ encoderOptions level)-        matchLenLimit = _matchLenLimit opts-        opts = encoderOptions level+        dictionarySize' = max (fromIntegral lZMinDictionarySize) . min (dictionarySize opts)+        matchLenLimit' = matchLenLimit opts