From 119f0e5fede64007be968bb038f562099a87267f Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 20 Aug 2016 03:59:31 -0400 Subject: Removed dependency on bits-extras. --- base32-bytestring.cabal | 7 ++++++- src/Data/ByteString/Base32/Internal.hs | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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: extra-source-files: README.md , ChangeLog +flag bits-extras + description: Use more-effecient bits-extras bitwise operations. + default: False + source-repository head type: git location: git://github.com/pxqr/base32-bytestring.git @@ -41,7 +45,8 @@ library build-depends: base == 4.* , bytestring >= 0.9 , cpu == 0.1.* - , bits-extras == 0.1.* + if flag(bits-extras) + build-depends: bits-extras == 0.1.* ghc-options: -O2 -Wall 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 import Prelude hiding (catch) #endif import Control.Exception hiding (mask) +#ifdef VERSION_bits_extras import Data.Bits.Extras +#endif import Data.ByteString as BS import Data.ByteString.Internal as BS import Data.Word @@ -46,11 +48,19 @@ type Word5 = Word8 -- intrinsics -- toBE64' :: Word64 -> Word64 +#ifdef VERSION_bits_extras toBE64' = if getSystemEndianness == BigEndian then id else byteSwap +#else +toBE64' = toBE64 +#endif {-# INLINE toBE64' #-} toBE32' :: Word32 -> Word32 +#ifdef VERSION_bits_extras toBE32' = if getSystemEndianness == BigEndian then id else byteSwap +#else +toBE32' = toBE32 +#endif {-# INLINE toBE32' #-} fromBE32' :: Word32 -> Word32 -- cgit v1.2.3