diff options
author | joe <joe@jerkface.net> | 2016-12-31 17:48:34 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2016-12-31 17:48:34 -0500 |
commit | 1d9049d914ccc9b66ff33e764618e8301d0b1ccf (patch) | |
tree | d2b6631b8bbc4fe094d848f08ccf22afa3d86738 /src/Data/Torrent.hs | |
parent | 6db720421a4fbfda957e7199464f16b6f261b40a (diff) |
Made bits-extras dependency optional.
Diffstat (limited to 'src/Data/Torrent.hs')
-rw-r--r-- | src/Data/Torrent.hs | 6 |
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 | |||
154 | import Data.BEncode as BE | 154 | import Data.BEncode as BE |
155 | import Data.BEncode.Types as BE | 155 | import Data.BEncode.Types as BE |
156 | import Data.Bits | 156 | import Data.Bits |
157 | #ifdef VERSION_bits_extras | ||
157 | import Data.Bits.Extras | 158 | import Data.Bits.Extras |
159 | #endif | ||
158 | import Data.ByteString as BS | 160 | import Data.ByteString as BS |
159 | import Data.ByteString.Base16 as Base16 | 161 | import Data.ByteString.Base16 as Base16 |
160 | import Data.ByteString.Base32 as Base32 | 162 | import Data.ByteString.Base32 as Base32 |
@@ -584,7 +586,11 @@ maxPieceSize = 4 * 1024 * 1024 | |||
584 | {-# INLINE maxPieceSize #-} | 586 | {-# INLINE maxPieceSize #-} |
585 | 587 | ||
586 | toPow2 :: Int -> Int | 588 | toPow2 :: Int -> Int |
589 | #ifdef VERSION_bits_extras | ||
587 | toPow2 x = bit $ fromIntegral (leadingZeros (0 :: Int) - leadingZeros x) | 590 | toPow2 x = bit $ fromIntegral (leadingZeros (0 :: Int) - leadingZeros x) |
591 | #else | ||
592 | toPow2 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. |
590 | defaultPieceSize :: Int64 -> Int | 596 | defaultPieceSize :: Int64 -> Int |