attoparsec parsers for all new-format uuid-based logs

There should be some speed gains here, especially for chunk and remote
state logs, which are queried once per key.

Now only old-format uuid-based logs still need to be converted to attoparsec.
This commit is contained in:
Joey Hess 2019-01-10 13:23:42 -04:00
parent 7e54c215b4
commit 66603d6f75
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
10 changed files with 88 additions and 56 deletions

View file

@ -20,6 +20,8 @@ import Logs.MapLog
import qualified Annex.Branch
import qualified Data.Map as M
import qualified Data.ByteString.Lazy as L
import qualified Data.Attoparsec.ByteString.Lazy as A
import Data.ByteString.Builder
type ConfigName = String
@ -35,7 +37,7 @@ setGlobalConfig' :: ConfigName -> ConfigValue -> Annex ()
setGlobalConfig' name new = do
c <- liftIO currentVectorClock
Annex.Branch.change configLog $
buildGlobalConfig . changeMapLog c name new . parseGlobalConfig . decodeBL
buildGlobalConfig . changeMapLog c name new . parseGlobalConfig
unsetGlobalConfig :: ConfigName -> Annex ()
unsetGlobalConfig name = do
@ -53,9 +55,11 @@ buildGlobalConfig = buildMapLog fieldbuilder valuebuilder
fieldbuilder = byteString . encodeBS
valuebuilder = byteString . encodeBS
parseGlobalConfig :: String -> MapLog ConfigName ConfigValue
parseGlobalConfig = parseMapLog Just Just
parseGlobalConfig :: L.ByteString -> MapLog ConfigName ConfigValue
parseGlobalConfig = parseMapLog string string
where
string = decodeBS <$> A.takeByteString
loadGlobalConfig :: Annex (M.Map ConfigName ConfigValue)
loadGlobalConfig = M.filter (not . null) . simpleMap . parseGlobalConfig . decodeBL
loadGlobalConfig = M.filter (not . null) . simpleMap . parseGlobalConfig
<$> Annex.Branch.get configLog