lzo 0.1.1.0 → 0.1.1.1
raw patch · 6 files changed
+76/−10 lines, 6 filesdep +criteriondep +digestdep −digest-puredep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: criterion, digest
Dependencies removed: digest-pure
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- bench/Bench.hs +19/−0
- lzo.cabal +31/−4
- src/Codec/Compression/Lzo.hs +2/−0
- src/Codec/Compression/Lzo/File.hs +10/−4
- test/Spec.hs +9/−2
CHANGELOG.md view
@@ -1,5 +1,10 @@ # lzo +## 0.1.1.1++ * Use [digest](http://hackage.haskell.org/package/digest) over+ [digest-pure](http://hackage.haskell.org/package/digest-pure).+ ## 0.1.1.0 * Added `lzoVersionString` etc.
+ bench/Bench.hs view
@@ -0,0 +1,19 @@+module Main (main) where++import Codec.Compression.Lzo+import Criterion.Main+import qualified Data.ByteString.Lazy as BSL++decompressBench :: FilePath -> IO ()+decompressBench fp' = forceBSL =<<+ (decompressFile <$> BSL.readFile fp')++ where forceBSL = (`seq` mempty) . last . BSL.toChunks++main :: IO ()+main =+ defaultMain [+ bgroup "decompress/file"+ [ bench "lzo" $ nfIO (decompressBench "../llvm-9.0.0.src.tar.lzo") ]+ ]+
lzo.cabal view
@@ -1,11 +1,12 @@-cabal-version: 1.18+cabal-version: 2.0 name: lzo-version: 0.1.1.0+version: 0.1.1.1 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2020 Vanessa McHale maintainer: vamchale@gmail.com author: Vanessa McHale+bug-reports: https://hub.darcs.net/vmchale/sak/issues synopsis: minilzo bundled for Haskell description: A small library wrapping minilzo allowing lzop compression in Haskell.@@ -41,7 +42,7 @@ build-depends: base >=4.9 && <5, bytestring -any,- digest-pure -any,+ digest -any, binary -any if impl(ghc >=8.0)@@ -58,7 +59,7 @@ if impl(ghc >=8.10) ghc-options: -Wunused-packages -test-suite lz4-test+test-suite lzo-test type: exitcode-stdio-1.0 main-is: Spec.hs hs-source-dirs: test@@ -69,6 +70,32 @@ lzo -any, tasty -any, tasty-hunit -any,+ bytestring -any++ if impl(ghc >=8.0)+ ghc-options:+ -Wincomplete-uni-patterns -Wincomplete-record-updates+ -Wredundant-constraints -Widentities++ if impl(ghc >=8.4)+ ghc-options: -Wmissing-export-lists++ if impl(ghc >=8.2)+ ghc-options: -Wcpp-undef++ if impl(ghc >=8.10)+ ghc-options: -Wunused-packages++benchmark lzo-bench+ type: exitcode-stdio-1.0+ main-is: Bench.hs+ hs-source-dirs: bench+ default-language: Haskell2010+ ghc-options: -Wall+ build-depends:+ base -any,+ lzo -any,+ criterion -any, bytestring -any if impl(ghc >=8.0)
src/Codec/Compression/Lzo.hs view
@@ -1,4 +1,6 @@ -- | Block functions throw 'LzoError' on error.+--+-- Frame decompression may throw exceptions on encountering bad data. module Codec.Compression.Lzo ( -- * Block compression compress , decompress
src/Codec/Compression/Lzo/File.hs view
@@ -9,8 +9,8 @@ import Data.Bits (Bits, (.&.), (.|.)) import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BSL-import Data.Digest.Pure.Adler32 (adler32)-import Data.Digest.Pure.CRC32 (crc32)+import Data.Digest.Adler32 (adler32)+import Data.Digest.CRC32 (crc32) import Data.Semigroup ((<>)) import Data.Word (Word32) @@ -26,6 +26,12 @@ type LzoBlock = Maybe BS.ByteString +-- getByte :: Word8 -> Get ()+-- getByte b = do+ -- b' <- getWord8+ -- unless (b' == b) $+ -- fail "Invalid magic byte; perhaps it is not an lzop file"+ getMagic :: Get () getMagic = do inp <- getByteString 9@@ -66,7 +72,7 @@ getLzoBlock :: Word32 -- ^ Flags -> Get LzoBlock-getLzoBlock ff = do+getLzoBlock ff = {-# SCC "getLzoBlock" #-} do -- uncompressed length dst <- getWord32be if dst == 0@@ -100,7 +106,7 @@ then decompress srcData (fromIntegral dst) else srcData when (hasFlag ff adler32dFlag) $ do- let actual = adler32 decData+ let actual = {-# SCC "adler32d" #-} adler32 decData unless (Just actual == dAdler) $ failChecksum dAdler actual when (hasFlag ff crc32dFlag) $ do
test/Spec.hs view
@@ -1,7 +1,6 @@ module Main (main) where import Codec.Compression.Lzo-import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BSL import Test.Tasty import Test.Tasty.HUnit@@ -12,11 +11,19 @@ let actual = decompressFile (compressFile contents) actual @?= contents +testDecompress :: FilePath -> TestTree+testDecompress fp = testCase ("Decompress " ++ fp) $ do+ res <- decompressFile <$> BSL.readFile fp+ let lByte = last (BSL.toChunks res)+ assertBool "Does not throw exception" (lByte `seq` True)+ main :: IO () main = defaultMain $- testGroup "lzo" [testFrames]+ testGroup "lzo" [ testFrames+ , testDecompress "test/data/minilzo.c.lzo"+ ] where testFrames = testGroup "Frame compression" $