From 82398611268452a19bd960d51a1868b7919ad36e Mon Sep 17 00:00:00 2001 From: Vincent Hanquez <vincent@typed.io> Date: Sat, 26 Jan 2019 09:01:28 +0000 Subject: [PATCH] add some of the update from #3 --- Data/Git/Delta.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Data/Git/Delta.hs b/Data/Git/Delta.hs index 3757f0c..8db781f 100644 --- a/Data/Git/Delta.hs +++ b/Data/Git/Delta.hs @@ -5,6 +5,7 @@ -- Stability : experimental -- Portability : unix -- +{-# LANGUAGE BangPatterns #-} module Data.Git.Delta ( Delta(..) , DeltaCmd(..) @@ -22,13 +23,13 @@ import qualified Data.Git.Parser as P import Data.Git.Imports -- | a delta is a source size, a destination size and a list of delta cmd -data Delta = Delta Word64 Word64 [DeltaCmd] +data Delta = Delta !Word64 !Word64 ![DeltaCmd] deriving (Show,Eq) -- | possible commands in a delta data DeltaCmd = - DeltaCopy ByteString -- command to insert this bytestring - | DeltaSrc Word64 Word64 -- command to copy from source (offset, size) + DeltaCopy !ByteString -- command to insert this bytestring + | DeltaSrc !Word64 !Word64 -- command to copy from source (offset, size) deriving (Show,Eq) -- | parse a delta. @@ -62,8 +63,9 @@ deltaParse = do let size = s1 .|. s2 .|. s3 return $ DeltaSrc offset (if size == 0 then 0x10000 else size) | otherwise = DeltaCopy <$> P.take (fromIntegral cmd) - word8cond cond sh = - if cond then (flip shiftL sh . fromIntegral) <$> P.anyByte else return 0 + + word8cond False _ = return 0 + word8cond True sh = flip shiftL sh . fromIntegral <$> P.anyByte -- | read one delta from a lazy bytestring. deltaRead :: [ByteString] -> Maybe Delta -- GitLab