snappy-framing 0.1.0 → 0.1.1
raw patch · 3 files changed
+32/−15 lines, 3 files
Files
- snappy-framing.cabal +6/−7
- src/Codec/Compression/Snappy/Framing.hs +4/−4
- src/Data/Digest/CRC32C.hs +22/−4
snappy-framing.cabal view
@@ -1,13 +1,14 @@ name: snappy-framing-version: 0.1.0+version: 0.1.1 synopsis: Snappy Framing Format in Haskell homepage: https://github.com/kim/snappy-framing-license: OtherLicense+bug-reports: https://github.com/kim/snappy-framing/issues+license: MPL-2.0 license-file: LICENSE author: Kim Altintop maintainer: kim.altintop@gmail.com copyright: Copyright (c) 2013 Kim Altintop-category: Codec+category: Codec, Compression build-type: Simple cabal-version: >=1.10 @@ -26,12 +27,10 @@ hs-source-dirs: src - ghc-options: -Wall -fwarn-tabs -funbox-strict-fields- ghc-prof-options: -prof -auto-all+ ghc-options: -Wall -fwarn-tabs -funbox-small-strict-fields exposed-modules: Codec.Compression.Snappy.Framing-- other-modules: Data.Digest.CRC32C+ Data.Digest.CRC32C build-depends: array >= 0.4
src/Codec/Compression/Snappy/Framing.hs view
@@ -32,9 +32,9 @@ , checksum , streamIdentifier , verify- ) where+ )+where -import Control.Applicative import Data.ByteString (ByteString) import Data.Binary (Binary(..)) import Data.Binary.Get@@ -81,8 +81,8 @@ chunktype <- getWord8 case chunktype of 0xff -> skip (length streamStart - 1) >> return StreamIdentifier- 0x00 -> return . uncurry Compressed =<< getData- 0x01 -> return . uncurry Uncompressed =<< getData+ 0x00 -> uncurry Compressed <$> getData+ 0x01 -> uncurry Uncompressed <$> getData x | x >= 0x02 && x <= 0x7f -> return $ Unskippable x | x >= 0x80 && x <= 0xfe -> return $ Skippable x | otherwise -> error "junk chunk type"
src/Data/Digest/CRC32C.hs view
@@ -1,3 +1,21 @@+-- |+-- Module : Data.Digest.CRC32C+-- Copyright : (c) 2013 Kim Altintop <kim.altintop@gmail.com>, Edward Kmett (?)+-- Maintainer : Kim Altintop <kim.altintop@gmail.com>+-- Stability : stable+-- Portability : non-portable (GHC extensions)+--++-- | Implementation of the CRC32C checksum algorithm.+--+-- The current implementation is in "pure" Haskell, thus does not take advantage+-- of hardware implementations available on several CPU types. It's performance+-- (throughput) is therefore possibly insufficient for certain classes of+-- applications.+--+-- Attribution: it is believed that the code is, at least partly, based on an+-- implementation by Edward Kmett, which has since vanished from the internet.+-- module Data.Digest.CRC32C ( crc32c , crc32c_update@@ -24,15 +42,15 @@ step crc bs = B.foldl step' crc bs where step' acc b = let x = table !!! ((acc .&. 0xff) `xor` fromIntegral b)- in x `xor` (acc `shiftR` 8)-{-# INLINEABLE step #-}+ in x `xor` (acc `shiftR` 8)+{-# INLINE step #-} (!!!) :: (IArray a e, Ix i, Integral i) => a i e -> i -> e arr !!! i = unsafeAt arr $ fromIntegral i-{-# INLINEABLE (!!!) #-}+{-# INLINE (!!!) #-} table :: UArray Word32 Word32-table = listArray (0,255) $+table = listArray (0,255) [ 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4 , 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb , 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b