packages feed

crc 0.1.1.1 → 0.1.2.0

raw patch · 8 files changed

+31/−17 lines, 8 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Digest.CRC: type family CRCWord a = r | r -> a;
+ Data.Digest.CRC: type CRCWord a = (r :: Type) | r -> a;

Files

bench/Main.hs view
@@ -9,6 +9,7 @@ import           Criterion import           Criterion.Main import           Data.ByteString   (ByteString)+import qualified Data.ByteString.Lazy as BL import           Data.Proxy ------------------------------------------------------------------------------- import           Data.Digest.CRC@@ -22,24 +23,34 @@ main :: IO () main = defaultMain   [ digestBenchmarks+  , digestBenchmarksBig   ]   ------------------------------------------------------------------------------- digestBenchmarks :: Benchmark digestBenchmarks = bgroup "digest"-  [ bench "CRC8" (digestBench (Proxy :: Proxy CRC8) )-  , bench "CRC16" (digestBench (Proxy :: Proxy CRC16))-  , bench "CRC32" (digestBench (Proxy :: Proxy CRC32))-  , bench "CRC64" (digestBench (Proxy :: Proxy CRC64))+  [ bench "CRC8" (digestBench (Proxy :: Proxy CRC8) example)+  , bench "CRC16" (digestBench (Proxy :: Proxy CRC16) example)+  , bench "CRC32" (digestBench (Proxy :: Proxy CRC32) example)+  , bench "CRC64" (digestBench (Proxy :: Proxy CRC64) example)   ] +digestBenchmarksBig :: Benchmark+digestBenchmarksBig = bgroup "digest_big"+  [ bench "CRC8" (digestBench (Proxy :: Proxy CRC8) bigExample)+  , bench "CRC16" (digestBench (Proxy :: Proxy CRC16) bigExample)+  , bench "CRC32" (digestBench (Proxy :: Proxy CRC32) bigExample)+  , bench "CRC64" (digestBench (Proxy :: Proxy CRC64) bigExample)+  ] + ------------------------------------------------------------------------------- example :: ByteString example = "1234567890" -+bigExample :: ByteString+bigExample = BL.toStrict (BL.fromChunks (replicate 1000000 example)) --------------------------------------------------------------------------------digestBench :: forall a. (CRC a) => Proxy a -> Benchmarkable-digestBench _ = whnf (digest :: ByteString -> a) example+digestBench :: forall a. (CRC a) => Proxy a -> ByteString -> Benchmarkable+digestBench _ bs = whnf (digest :: ByteString -> a) bs
changelog.md view
@@ -1,3 +1,6 @@+0.1.2.0+* Use strict fold on ByteString for memory efficiency [#4](https://github.com/MichaelXavier/crc/pull/4)+ 0.1.1.1 * Export `digestWithInitial`[#3](https://github.com/MichaelXavier/crc/pull/3) 
crc.cabal view
@@ -1,5 +1,5 @@ name:                crc-version:             0.1.1.1+version:             0.1.2.0 synopsis:            Implements various Cyclic Redundancy Checks (CRC) description:         ByteString-based Cyclic Redundancy Checks homepage:            http://github.com/MichaelXavier/crc@@ -71,7 +71,7 @@   if flag(lib-Werror)     ghc-options: -Werror -  ghc-options: -Wall+  ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-K50M   source-repository head
src/Data/Digest/CRC.hs view
src/Data/Digest/CRC16.hs view
@@ -27,12 +27,12 @@  ------------------------------------------------------------------------------- updateDigest16 :: CRC16 -> ByteString -> CRC16-updateDigest16 crc = BS.foldl go crc+updateDigest16 crc = BS.foldl' go crc   where     go (CRC16 crc') b8 =       let idx = fromIntegral (crc' `xor` b16) .&. 0xff           b16 = fromIntegral b8-      in CRC16 ((table ! idx) `xor` ((crc' `shiftR` 8) .&. 0x00ffff))+      in CRC16 ((table `V.unsafeIndex` idx) `xor` ((crc' `shiftR` 8) .&. 0x00ffff))   -------------------------------------------------------------------------------
src/Data/Digest/CRC32.hs view
@@ -29,13 +29,13 @@  ------------------------------------------------------------------------------- updateDigest32 :: CRC32 -> ByteString -> CRC32-updateDigest32 crc = xorFinal . BS.foldl go crc+updateDigest32 crc = xorFinal . BS.foldl' go crc   where     xorFinal (CRC32 x) = CRC32 (x `xor` 0xffffffff)     go (CRC32 crc') b8 =       let idx = fromIntegral (crc' `xor` b32) .&. 0xff           b32 = fromIntegral b8-      in CRC32 (((crc' `shiftR` 8) .&. 0x00ffffff) `xor` (table ! idx))+      in CRC32 (((crc' `shiftR` 8) .&. 0x00ffffff) `xor` (table `V.unsafeIndex` idx))   -------------------------------------------------------------------------------
src/Data/Digest/CRC64.hs view
@@ -29,12 +29,12 @@  ------------------------------------------------------------------------------- updateDigest64 :: CRC64 -> ByteString -> CRC64-updateDigest64 crc = BS.foldl go crc+updateDigest64 crc = BS.foldl' go crc   where     go (CRC64 crc') b8 =       let idx = fromIntegral (crc' `xor` b64) .&. 0xff           b64 = fromIntegral b8-      in CRC64 (((table ! idx) `xor` (crc' `shiftR` 8)) .&. 0xffffffffffffffff)+      in CRC64 (((table `V.unsafeIndex` idx) `xor` (crc' `shiftR` 8)) .&. 0xffffffffffffffff)   -------------------------------------------------------------------------------
src/Data/Digest/CRC8.hs view
@@ -27,11 +27,11 @@  ------------------------------------------------------------------------------- updateDigest8 :: CRC8 -> ByteString -> CRC8-updateDigest8 crc = BS.foldl go crc+updateDigest8 crc = BS.foldl' go crc   where     go (CRC8 crc') b8 =       let idx = fromIntegral (crc' `xor` b8) .&. 0xff-      in CRC8 ((table ! idx) `xor` ((crc' `shiftR` 8) .&. 0xff))+      in CRC8 ((table `V.unsafeIndex` idx) `xor` ((crc' `shiftR` 8) .&. 0xff))   -------------------------------------------------------------------------------