File tree Expand file tree Collapse file tree 3 files changed +12
-14
lines changed
src/System/Nix/Store/Remote Expand file tree Collapse file tree 3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ library
2222 , System.Nix.Store.Remote.Util
2323
2424 build-depends : base >= 4.10 && < 5
25- , cryptonite
2625 , bytestring
2726 , binary
2827 , bytestring
Original file line number Diff line number Diff line change @@ -16,6 +16,16 @@ putInt = putWord64le . fromIntegral
1616getInt :: Integral a => Get a
1717getInt = fromIntegral <$> getWord64le
1818
19+ putMany :: Foldable t => (a -> Put ) -> t a -> Put
20+ putMany printer xs = do
21+ putInt (length xs)
22+ mapM_ printer xs
23+
24+ getMany :: Get a -> Get [a ]
25+ getMany parser = do
26+ count <- getInt
27+ replicateM count parser
28+
1929-- length prefixed string packing with padding to 8 bytes
2030putByteStringLen :: BSL. ByteString -> Put
2131putByteStringLen x = do
@@ -29,9 +39,7 @@ putByteStringLen x = do
2939 pad count = sequence_ $ replicate count (putWord8 0 )
3040
3141putByteStrings :: Foldable t => t BSL. ByteString -> Put
32- putByteStrings xs = do
33- putInt $ length xs
34- mapM_ putByteStringLen xs
42+ putByteStrings = putMany putByteStringLen
3543
3644getByteStringLen :: Get ByteString
3745getByteStringLen = do
@@ -44,8 +52,4 @@ getByteStringLen = do
4452 where unpad x = sequence $ replicate x getWord8
4553
4654getByteStrings :: Get [ByteString ]
47- getByteStrings = do
48- count <- getInt
49- res <- sequence $ replicate count getByteStringLen
50- return res
51-
55+ getByteStrings = getMany getByteStringLen
Original file line number Diff line number Diff line change @@ -132,11 +132,6 @@ putTime = (putInt :: Int -> Put) . round . utcTimeToPOSIXSeconds
132132getTime :: Get UTCTime
133133getTime = posixSecondsToUTCTime <$> getEnum
134134
135- getMany :: Get a -> Get [a ]
136- getMany parser = do
137- count <- getInt
138- replicateM count parser
139-
140135getBuildResult :: Get BuildResult
141136getBuildResult = BuildResult
142137 <$> getEnum
You can’t perform that action at this time.
0 commit comments