lzlib 0.3.1.1 → 0.3.1.2
raw patch · 4 files changed
+22/−17 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- LICENSE +1/−1
- lzlib.cabal +2/−2
- src/Codec/Lzip.hs +15/−14
CHANGELOG.md view
@@ -1,5 +1,9 @@ # lzlib +## 0.3.1.2++ * Hopefully improved performance+ ## 0.3.1.1 * Bug fix + more sensible memory use
LICENSE view
@@ -1,4 +1,4 @@-Copyright Vanessa McHale (c) 2019+Copyright Vanessa McHale (c) 2019-2020 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
lzlib.cabal view
@@ -1,9 +1,9 @@ cabal-version: 1.18 name: lzlib-version: 0.3.1.1+version: 0.3.1.2 license: BSD3 license-file: LICENSE-copyright: Copyright: (c) 2019 Vanessa McHale+copyright: Copyright: (c) 2019-2020 Vanessa McHale maintainer: vamchale@gmail.com author: Vanessa McHale synopsis: lzlib bindings
src/Codec/Lzip.hs view
@@ -9,16 +9,17 @@ ) where import Codec.Lzip.Raw-import Control.Exception (bracket)-import Control.Monad (void, when)-import Data.Bits (shiftL)-import qualified Data.ByteString as BS-import qualified Data.ByteString.Lazy as BSL-import Data.Functor (($>))-import Data.Int (Int64)-import Foreign.Marshal.Alloc (free, mallocBytes)-import Foreign.Ptr (Ptr, castPtr)-import System.IO.Unsafe (unsafeDupablePerformIO)+import Control.Exception (bracket)+import Control.Monad (void, when)+import Data.Bits (shiftL)+import qualified Data.ByteString as BS+import qualified Data.ByteString.Lazy as BSL+import qualified Data.ByteString.Unsafe as BS+import Data.Functor (($>))+import Data.Int (Int64)+import Foreign.Marshal.Alloc (free, mallocBytes)+import Foreign.Ptr (Ptr, castPtr)+import System.IO.Unsafe (unsafeDupablePerformIO) data CompressionLevel = Zero | One@@ -91,10 +92,10 @@ (bs':bss') -> if BS.length bs' > maxSz then do let (bs'', rest) = BS.splitAt maxSz bs'- BS.useAsCStringLen bs'' $ \(bytes, sz) ->+ BS.unsafeUseAsCStringLen bs'' $ \(bytes, sz) -> lZDecompressWrite decoder (castPtr bytes) (fromIntegral sz) $> rest:bss' else- BS.useAsCStringLen bs' $ \(bytes, sz) ->+ BS.unsafeUseAsCStringLen bs' $ \(bytes, sz) -> lZDecompressWrite decoder (castPtr bytes) (fromIntegral sz) $> bss' [] -> pure []@@ -140,10 +141,10 @@ loop :: LZEncoderPtr -> [BS.ByteString] -> (Ptr UInt8, Int) -> Int -> [BS.ByteString] -> IO [BS.ByteString] loop encoder bss (buf, sz) bytesRead acc = do bss' <- case bss of- [bs] -> BS.useAsCStringLen bs $ \(bytes, sz') -> do+ [bs] -> BS.unsafeUseAsCStringLen bs $ \(bytes, sz') -> do void $ lZCompressWrite encoder (castPtr bytes) (fromIntegral sz') lZCompressFinish encoder $> []- (bs:bss') -> BS.useAsCStringLen bs $ \(bytes, sz') ->+ (bs:bss') -> BS.unsafeUseAsCStringLen bs $ \(bytes, sz') -> lZCompressWrite encoder (castPtr bytes) (fromIntegral sz') $> bss' [] -> pure [] bytesActual <- lZCompressRead encoder buf (fromIntegral sz)