diff options
Diffstat (limited to 'src/Data/Bitfield.hs')
-rw-r--r-- | src/Data/Bitfield.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Data/Bitfield.hs b/src/Data/Bitfield.hs index 89461fd2..acfca0d0 100644 --- a/src/Data/Bitfield.hs +++ b/src/Data/Bitfield.hs | |||
@@ -236,28 +236,28 @@ rarest xs | |||
236 | 236 | ||
237 | -- | Find indices at least one peer have. | 237 | -- | Find indices at least one peer have. |
238 | union :: Bitfield -> Bitfield -> Bitfield | 238 | union :: Bitfield -> Bitfield -> Bitfield |
239 | union a b = Bitfield { | 239 | union a b = {-# SCC union #-} Bitfield { |
240 | bfSize = bfSize a `max` bfSize b | 240 | bfSize = bfSize a `max` bfSize b |
241 | , bfSet = bfSet a `S.union` bfSet b | 241 | , bfSet = bfSet a `S.union` bfSet b |
242 | } | 242 | } |
243 | 243 | ||
244 | -- | Find indices both peers have. | 244 | -- | Find indices both peers have. |
245 | intersection :: Bitfield -> Bitfield -> Bitfield | 245 | intersection :: Bitfield -> Bitfield -> Bitfield |
246 | intersection a b = Bitfield { | 246 | intersection a b = {-# SCC intersection #-} Bitfield { |
247 | bfSize = bfSize a `min` bfSize b | 247 | bfSize = bfSize a `min` bfSize b |
248 | , bfSet = bfSet a `S.intersection` bfSet b | 248 | , bfSet = bfSet a `S.intersection` bfSet b |
249 | } | 249 | } |
250 | 250 | ||
251 | -- | Find indices which have first peer but do not have the second peer. | 251 | -- | Find indices which have first peer but do not have the second peer. |
252 | difference :: Bitfield -> Bitfield -> Bitfield | 252 | difference :: Bitfield -> Bitfield -> Bitfield |
253 | difference a b = Bitfield { | 253 | difference a b = {-# SCC difference #-} Bitfield { |
254 | bfSize = bfSize a -- FIXME is it reasonable? | 254 | bfSize = bfSize a -- FIXME is it reasonable? |
255 | , bfSet = bfSet a `S.difference` bfSet b | 255 | , bfSet = bfSet a `S.difference` bfSet b |
256 | } | 256 | } |
257 | 257 | ||
258 | -- | Find indices the any of the peers have. | 258 | -- | Find indices the any of the peers have. |
259 | unions :: [Bitfield] -> Bitfield | 259 | unions :: [Bitfield] -> Bitfield |
260 | unions = foldl' union (haveNone 0) | 260 | unions = {-# SCC unions #-} foldl' union (haveNone 0) |
261 | 261 | ||
262 | {----------------------------------------------------------------------- | 262 | {----------------------------------------------------------------------- |
263 | Serialization | 263 | Serialization |
@@ -270,7 +270,7 @@ toList Bitfield {..} = S.toList bfSet | |||
270 | -- | Unpack 'Bitfield' from tightly packed bit array. Note resulting | 270 | -- | Unpack 'Bitfield' from tightly packed bit array. Note resulting |
271 | -- size might be more than real bitfield size, use 'adjustSize'. | 271 | -- size might be more than real bitfield size, use 'adjustSize'. |
272 | fromBitmap :: ByteString -> Bitfield | 272 | fromBitmap :: ByteString -> Bitfield |
273 | fromBitmap bs = Bitfield { | 273 | fromBitmap bs = {-# SCC fromBitmap #-} Bitfield { |
274 | bfSize = B.length bs * 8 | 274 | bfSize = B.length bs * 8 |
275 | , bfSet = S.fromByteString bs | 275 | , bfSet = S.fromByteString bs |
276 | } | 276 | } |
@@ -278,7 +278,7 @@ fromBitmap bs = Bitfield { | |||
278 | 278 | ||
279 | -- | Pack a 'Bitfield' to tightly packed bit array. | 279 | -- | Pack a 'Bitfield' to tightly packed bit array. |
280 | toBitmap :: Bitfield -> Lazy.ByteString | 280 | toBitmap :: Bitfield -> Lazy.ByteString |
281 | toBitmap Bitfield {..} = Lazy.fromChunks [intsetBM, alignment] | 281 | toBitmap Bitfield {..} = {-# SCC toBitmap #-} Lazy.fromChunks [intsetBM, alignment] |
282 | where | 282 | where |
283 | byteSize = bfSize `div` 8 + if bfSize `mod` 8 == 0 then 0 else 1 | 283 | byteSize = bfSize `div` 8 + if bfSize `mod` 8 == 0 then 0 else 1 |
284 | alignment = B.replicate (byteSize - B.length intsetBM) 0 | 284 | alignment = B.replicate (byteSize - B.length intsetBM) 0 |