diff options
author | joe <joe@jerkface.net> | 2016-08-20 03:59:31 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2016-08-20 03:59:31 -0400 |
commit | 119f0e5fede64007be968bb038f562099a87267f (patch) | |
tree | ed437347d4f9e84cc4004fa457b0f901bfcd50b7 | |
parent | 3a6fe39aa734fd053baababdc8afa413999c8cd1 (diff) |
-rw-r--r-- | base32-bytestring.cabal | 7 | ||||
-rw-r--r-- | src/Data/ByteString/Base32/Internal.hs | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/base32-bytestring.cabal b/base32-bytestring.cabal index a96d3fa..aa82911 100644 --- a/base32-bytestring.cabal +++ b/base32-bytestring.cabal | |||
@@ -20,6 +20,10 @@ description: | |||
20 | extra-source-files: README.md | 20 | extra-source-files: README.md |
21 | , ChangeLog | 21 | , ChangeLog |
22 | 22 | ||
23 | flag bits-extras | ||
24 | description: Use more-effecient bits-extras bitwise operations. | ||
25 | default: False | ||
26 | |||
23 | source-repository head | 27 | source-repository head |
24 | type: git | 28 | type: git |
25 | location: git://github.com/pxqr/base32-bytestring.git | 29 | location: git://github.com/pxqr/base32-bytestring.git |
@@ -41,7 +45,8 @@ library | |||
41 | build-depends: base == 4.* | 45 | build-depends: base == 4.* |
42 | , bytestring >= 0.9 | 46 | , bytestring >= 0.9 |
43 | , cpu == 0.1.* | 47 | , cpu == 0.1.* |
44 | , bits-extras == 0.1.* | 48 | if flag(bits-extras) |
49 | build-depends: bits-extras == 0.1.* | ||
45 | ghc-options: -O2 -Wall | 50 | ghc-options: -O2 -Wall |
46 | 51 | ||
47 | test-suite spec | 52 | test-suite spec |
diff --git a/src/Data/ByteString/Base32/Internal.hs b/src/Data/ByteString/Base32/Internal.hs index aa7c5b3..31f6e30 100644 --- a/src/Data/ByteString/Base32/Internal.hs +++ b/src/Data/ByteString/Base32/Internal.hs | |||
@@ -26,7 +26,9 @@ module Data.ByteString.Base32.Internal | |||
26 | import Prelude hiding (catch) | 26 | import Prelude hiding (catch) |
27 | #endif | 27 | #endif |
28 | import Control.Exception hiding (mask) | 28 | import Control.Exception hiding (mask) |
29 | #ifdef VERSION_bits_extras | ||
29 | import Data.Bits.Extras | 30 | import Data.Bits.Extras |
31 | #endif | ||
30 | import Data.ByteString as BS | 32 | import Data.ByteString as BS |
31 | import Data.ByteString.Internal as BS | 33 | import Data.ByteString.Internal as BS |
32 | import Data.Word | 34 | import Data.Word |
@@ -46,11 +48,19 @@ type Word5 = Word8 | |||
46 | -- intrinsics | 48 | -- intrinsics |
47 | -- | 49 | -- |
48 | toBE64' :: Word64 -> Word64 | 50 | toBE64' :: Word64 -> Word64 |
51 | #ifdef VERSION_bits_extras | ||
49 | toBE64' = if getSystemEndianness == BigEndian then id else byteSwap | 52 | toBE64' = if getSystemEndianness == BigEndian then id else byteSwap |
53 | #else | ||
54 | toBE64' = toBE64 | ||
55 | #endif | ||
50 | {-# INLINE toBE64' #-} | 56 | {-# INLINE toBE64' #-} |
51 | 57 | ||
52 | toBE32' :: Word32 -> Word32 | 58 | toBE32' :: Word32 -> Word32 |
59 | #ifdef VERSION_bits_extras | ||
53 | toBE32' = if getSystemEndianness == BigEndian then id else byteSwap | 60 | toBE32' = if getSystemEndianness == BigEndian then id else byteSwap |
61 | #else | ||
62 | toBE32' = toBE32 | ||
63 | #endif | ||
54 | {-# INLINE toBE32' #-} | 64 | {-# INLINE toBE32' #-} |
55 | 65 | ||
56 | fromBE32' :: Word32 -> Word32 | 66 | fromBE32' :: Word32 -> Word32 |