summaryrefslogtreecommitdiff
path: root/src/Data
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2016-12-31 17:48:34 -0500
committerjoe <joe@jerkface.net>2016-12-31 17:48:34 -0500
commit1d9049d914ccc9b66ff33e764618e8301d0b1ccf (patch)
treed2b6631b8bbc4fe094d848f08ccf22afa3d86738 /src/Data
parent6db720421a4fbfda957e7199464f16b6f261b40a (diff)
Made bits-extras dependency optional.
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/Torrent.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs
index d6f141a8..6bec665e 100644
--- a/src/Data/Torrent.hs
+++ b/src/Data/Torrent.hs
@@ -154,7 +154,9 @@ import Crypto.Hash.SHA1 as SHA1
154import Data.BEncode as BE 154import Data.BEncode as BE
155import Data.BEncode.Types as BE 155import Data.BEncode.Types as BE
156import Data.Bits 156import Data.Bits
157#ifdef VERSION_bits_extras
157import Data.Bits.Extras 158import Data.Bits.Extras
159#endif
158import Data.ByteString as BS 160import Data.ByteString as BS
159import Data.ByteString.Base16 as Base16 161import Data.ByteString.Base16 as Base16
160import Data.ByteString.Base32 as Base32 162import Data.ByteString.Base32 as Base32
@@ -584,7 +586,11 @@ maxPieceSize = 4 * 1024 * 1024
584{-# INLINE maxPieceSize #-} 586{-# INLINE maxPieceSize #-}
585 587
586toPow2 :: Int -> Int 588toPow2 :: Int -> Int
589#ifdef VERSION_bits_extras
587toPow2 x = bit $ fromIntegral (leadingZeros (0 :: Int) - leadingZeros x) 590toPow2 x = bit $ fromIntegral (leadingZeros (0 :: Int) - leadingZeros x)
591#else
592toPow2 x = bit $ fromIntegral (countLeadingZeros (0 :: Int) - countLeadingZeros x)
593#endif
588 594
589-- | Find the optimal piece size for a given torrent size. 595-- | Find the optimal piece size for a given torrent size.
590defaultPieceSize :: Int64 -> Int 596defaultPieceSize :: Int64 -> Int