packages feed

lzlib 1.0.6.0 → 1.0.7.0

raw patch · 5 files changed

+68/−14 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Codec.Lzip: instance GHC.Enum.Bounded Codec.Lzip.CompressionLevel

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # lzlib +## 1.0.7.0++  * Add `Bounded` instance to `CompressionLevel`+ ## 1.0.6.0    * Export `compressFineTune`
lzlib.cabal view
@@ -1,6 +1,6 @@ cabal-version:      1.18 name:               lzlib-version:            1.0.6.0+version:            1.0.7.0 license:            BSD3 license-file:       LICENSE copyright:          Copyright: (c) 2019-2020 Vanessa McHale@@ -66,11 +66,15 @@     if impl(ghc >=8.4)         ghc-options: -Wmissing-export-lists +    if impl(ghc >=8.10)+        ghc-options: -Wunused-packages+ test-suite lzlib-test     type:             exitcode-stdio-1.0     main-is:          Spec.hs     hs-source-dirs:   test     default-language: Haskell2010+    ghc-options:      -threaded -rtsopts -with-rtsopts=-N -Wall     build-depends:         base -any,         lzlib -any,@@ -87,6 +91,9 @@     if impl(ghc >=8.4)         ghc-options: -Wmissing-export-lists +    if impl(ghc >=8.10)+        ghc-options: -Wunused-packages+ benchmark lzlib-bench     type:             exitcode-stdio-1.0     main-is:          Bench.hs@@ -107,12 +114,15 @@     if impl(ghc >=8.4)         ghc-options: -Wmissing-export-lists +    if impl(ghc >=8.10)+        ghc-options: -Wunused-packages+ benchmark lzlib-mem     type:             exitcode-stdio-1.0     main-is:          Mem.hs     hs-source-dirs:   mem     default-language: Haskell2010-    ghc-options:      -Wall+    ghc-options:      -threaded -rtsopts -with-rtsopts=-N -Wall     build-depends:         base -any,         lzlib -any,@@ -122,3 +132,6 @@      if impl(ghc >=8.0)         ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates++    if impl(ghc >=8.10)+        ghc-options: -Wunused-packages
mem/Mem.hs view
@@ -1,14 +1,16 @@ module Main (main) where  import           Codec.Lzip           (compressFile, decompress)+import           Control.Concurrent   (forkIO, newEmptyMVar, putMVar, takeMVar)+import qualified Data.ByteString      as BS import qualified Data.ByteString.Lazy as BSL import           System.FilePath      ((</>)) import           System.IO.Temp       (withSystemTempDirectory)- main :: IO () main =     compressDump *>-    decompressDump+    decompressDump *>+    compressMultithreaded "gmp-6.1.2.tar"  decompressDump :: IO () decompressDump = withSystemTempDirectory "lz" $@@ -19,3 +21,17 @@ compressDump = withSystemTempDirectory "lz" $     \fp -> BSL.writeFile (fp </> "gmp-6.1.2.tar.lz") =<<         (compressFile "gmp-6.1.2.tar")++forceHead :: BSL.ByteString -> IO ()+forceHead bsl = BS.length (head $ BSL.toChunks bsl) `seq` mempty++forceBSL :: BSL.ByteString -> IO ()+forceBSL bsl = BS.length (last $ BSL.toChunks bsl) `seq` mempty++compressMultithreaded :: FilePath -> IO ()+compressMultithreaded fp = do+    bsl <- compressFile fp -- compress <$> BSL.readFile fp+    forceHead bsl+    done <- newEmptyMVar+    _ <- forkIO (forceBSL bsl *> putMVar done ())+    takeMVar done
src/Codec/Lzip.hs view
@@ -64,7 +64,7 @@     | Seven     | Eight     | Nine-    deriving (Enum)+    deriving (Enum, Bounded)  data LzOptions = LzOptions     { dictionarySize :: !Int@@ -160,33 +160,33 @@            -> BSL.ByteString compressSz = compressWithSz Six --- | Alias for @'compressWithSz' 'Nine'@+-- | Alias for @'compressWithSz' 'maxBound'@ -- -- @since 1.0.2.0 compressSzBest :: BSL.ByteString            -> Int -- ^ Size of input data, in bytes            -> BSL.ByteString-compressSzBest = compressWithSz Nine+compressSzBest = compressWithSz maxBound --- | Alias for @'compressWithSz' 'Zero'@+-- | Alias for @'compressWithSz' 'minBound'@ -- -- @since 1.0.2.0 compressSzFast :: BSL.ByteString            -> Int -- ^ Size of input data, in bytes            -> BSL.ByteString-compressSzFast = compressWithSz Zero+compressSzFast = compressWithSz minBound --- | Alias for @'compressWith' 'Nine'@+-- | Alias for @'compressWith' 'maxBound'@ -- -- @since 0.3.2.0 compressBest :: BSL.ByteString -> BSL.ByteString-compressBest = compressWith Nine+compressBest = compressWith maxBound --- | Alias for @'compressWith' 'Zero'@+-- | Alias for @'compressWith' 'minBound'@ -- -- @since 0.3.2.0 compressFast :: BSL.ByteString -> BSL.ByteString-compressFast = compressWith Zero+compressFast = compressWith minBound  -- | Use this to avoid forcing the whole file into memory at once --@@ -196,7 +196,7 @@  -- | @since 1.0.3.0 compressFileBest :: FilePath -> IO BSL.ByteString-compressFileBest = compressFileLevel Nine+compressFileBest = compressFileLevel maxBound  -- | @since 1.0.3.0 compressFileFast :: FilePath -> IO BSL.ByteString
test/Spec.hs view
@@ -3,13 +3,31 @@ import           Codec.Lzip                   (compress, compressBest,                                                decompress) import           Control.Applicative+import           Control.Concurrent           (forkIO, newEmptyMVar, putMVar,+                                               readMVar) import           Control.Monad                (filterM)+import qualified Data.ByteString              as BS import qualified Data.ByteString.Lazy         as BSL import           Data.ByteString.Pathological (nonstandardRead) import           Data.Foldable                (traverse_) import           System.Directory             (doesFileExist) import           Test.Hspec +forceHead :: BSL.ByteString -> IO ()+forceHead bsl = BS.length (head $ BSL.toChunks bsl) `seq` (pure ())++forceBSL :: BSL.ByteString -> IO ()+forceBSL bsl = BS.length (last $ BSL.toChunks bsl) `seq` (pure ())++decompressMultithreaded :: FilePath -> IO ()+decompressMultithreaded fp = do+    bsl <- decompress <$> BSL.readFile fp+    forceHead bsl+    done <- newEmptyMVar+    _ <- forkIO (forceBSL bsl *> putMVar done ())+    _ <- forkIO (forceBSL bsl *> putMVar done ())+    readMVar done+ compressFileGeneral :: (FilePath -> IO BSL.ByteString) -> FilePath -> Spec compressFileGeneral f fp = parallel $     it ("decompress . compress should be identity (" ++ fp ++ ")") $ do@@ -47,3 +65,6 @@             traverse_ compressFileFreaky ex         describe "roundtrip (sketchy)" $             traverse_ decompressFileFreaky ex'+        describe "decompress (multithreaded)" $+            it "should not fail" $+                traverse_ decompressMultithreaded ex'