converting more log files to use Builder

Probably not any particular speedup in this, since most of these logs
are not written to often. Possibly chunk log writing is sped up, but
writes to chunk logs are interleaved with expensive data transfers to
remotes, so unlikely to be a noticiable speedup.
This commit is contained in:
Joey Hess 2019-01-09 13:06:37 -04:00
parent 5500cbbc30
commit 2d46038754
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
12 changed files with 91 additions and 56 deletions

View file

@ -3,7 +3,7 @@
- We don't have a way yet to keep true distributed vector clocks.
- The next best thing is a timestamp.
-
- Copyright 2017 Joey Hess <id@joeyh.name>
- Copyright 2017-2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@ -11,12 +11,14 @@
module Annex.VectorClock where
import Data.Time.Clock.POSIX
import Data.ByteString.Builder
import Control.Applicative
import Prelude
import Utility.Env
import Utility.TimeStamp
import Utility.QuickCheck
import Utility.FileSystemEncoding
import qualified Data.Attoparsec.ByteString.Lazy as A
-- | Some very old logs did not have any time stamp at all;
@ -40,9 +42,12 @@ currentVectorClock = go =<< getEnv "GIT_ANNEX_VECTOR_CLOCK"
Nothing -> VectorClock <$> getPOSIXTime
formatVectorClock :: VectorClock -> String
formatVectorClock Unknown = "0"
formatVectorClock Unknown = "0"
formatVectorClock (VectorClock t) = show t
buildVectorClock :: VectorClock -> Builder
buildVectorClock = byteString . encodeBS' . formatVectorClock
parseVectorClock :: String -> Maybe VectorClock
parseVectorClock t = VectorClock <$> parsePOSIXTime t